Mail Archives: djgpp/1998/12/30/03:30:43
Martin Ambuhl wrote:
>
> Michael Lehotay wrote:
> >
> > I've started to teach myself C++ from Stroustrup (3rd ed.), and I've run
> > into a problem: there is no <limits> header file. I realize I could use
> > <limits.h> instead, but what I really wanted was numeric_limits.
>
> When there is a C header named <x.h>, the corresponding C++ header is
> called <cx>. In this case, it is <climits>.
>
> An unfortunate problem with BS's 3rd ed is a large number of errata,
> which are listing in several files at the wed site you can reach through
> the URL on the back cover of your book.
Let me rephrase my question. I cannot compile this code:
#include <limits>
int main() {
cout << "largest int: " << numeric_limits<int>::max() << '\n';
return 0;
}
The problem is that the <limits> header file, which supposedly defines
numeric_limits, seems to be missing. <climits> just #includes <limits.h>,
which only #defines limit macros. I could use these macros to do the same
thing, but my point is that I want to learn how to program in C++ instead
of just writing C code with the same functionality.
Am I correct in my assumption that I'll just have to live without
numeric_limits? If so, should I expect to run into more surprises like
this?
Thanks,
Michael
- Raw text -