Getdate function in More C++ : LUSENET : Steve Heller's books : One Thread

I'm confused in Who's afraid of MORE C++?. In your description of the date type and it's use in the Today() function, there's something I don't get. The getdate function is stated to be a leftover C function. The date type is obviously C++. So we must be dealing with a newer incarnation of this getdate function, as it takes a C++ object as an argument. I have several questions gnawing at me.

First, what does a date variable look like? Obviously it has at least 3 public member variables, da_year, da_day and da_month. Does it have any other variables or functions I should be aware of? And,

Second, how did C programmers use this getdate function? You know, before the ++ thing came along. Specifically, what did they pass to it as arguments? 3 addresses to be filled? How was this specified? And, for that matter, what does this function return to a C programmer? I do of course realize that none of these questions are really necessary if I simply shut up and duplicate the code in your book, but I'm not fully satisfied with just a taste like that. I want to know more. This leads me to -

Third, where can someone such as myself find this information without hassling you all the time? There has to be some reference somewhere that gives a full description of the standard C++ library from which I could learn more. If I keep writing you every time I come across a new function you'll wish you weren't so friendly with your readers. Still, though, I would appreciate it if you could address the above questions yourself, and I promise I'll leave you alone on the rest of my exploration of the library functions. Assuming, of course, that there is somewhere else I can turn.

Thanks much for your time.

-- Mike Mannakee (, May 09, 1999


No, actually the date type is C. C already had the notion of a group of data which behaved like one item, the "struct". The great innovation of C++ was to add member functions to the data so that the operations on the data could be controlled.

The date type definitely doesn't have any member functions, because they didn't exist in C. As suggested above, C programmers used getdate exactly as C++ programmers do, because structs already existed in C.

As for how you can learn more about C++, I suggest that you get "The C++ Programming Language", by Bjarne Stroustrup, which I believe has the references you're looking for. Unfortunately, it's not very accessible to relative newcomers to the language, as it assumes too much about your prior knowledge. I'm sure Bjarne would disagree with that assessment, but then he obviously didn't have a novice explaining her confusion to him.

To be fair, it would be an immense task to try to explain the entire language in the amount of detail that I have used in the "Who's Afraid of ..." series. At some point, it's necessary to assume that the reader has some experience using the language.

As for getting too many questions from readers, I'm not too worried about that. After all, my readers have leapt to my defense on a number of occasions, and have contributed many wonderful reviews of my books on I suspect part of the reason is my willingness to try to help them over the rough spots, so it seems a fair exchange.

However, it isn't a very efficient use of my time to answer the same questions over and over, which is the reason for this discussion group.

-- Steve Heller (, May 09, 1999.

OS-specific header files and string DatedStockitem::Today() in

I'm also at odds with the Today member function in from your fabulous book Learning to program C++. I'm compiling the examples on a Linux system with gcc 2.95.3 (Kdevelop as an IDE) and occasionally had to modify the #include statements. Same with, had to take out #include . So far, so good. Now, compiling gives an "undeclared" error for 'date' and subsequent errors. Tried #including but that doesn't help. Has this something to do with the ANSI C++ Standard libs? I'd appreciate if you could broaden the discussion in the book to cover other platforms, too, though it is understandable to concentrate on the platform and compiler that come on the CD. So this might be the right forum to ask such a question after all. TIA! Christoph

-- Christoph Hammann (, November 10, 2001.

Ooops! BBS weirdness

In my previous message sharp brackets and what's in them are not displayed, in order to discourage HTML code, I suppose. So, I meant I had to take take out the include statement for the header file dos.h and later put in an include statement for ctime, which didn't help. Thank you!


-- Christoph Hammann (, November 10, 2001.


How embarrassing! I just should have read on a few pages, to where it explicitly says that dos.h is needed for the implementation of Today() and that these examples won't work on *nix systems for lack of this header file. You hint at a different solution for these platforms, but say nothing further on it. It doesn't seem to be as easy as using another standard header file, I've at least seen nothing appropriate in /usr/include/g++. Even B.Stroustrup's book "The C++ programming language" says nothing about it. Can you provide links to further explanations? Is this perhaps covered in your other C++ books?

Bye, Christoph

-- Christoph Hammann (, November 12, 2001.

Moderation questions? read the FAQ