RE: [Dev-C++] Derived class initialization
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Schedler, K. <Kur...@hi...> - 2001-06-25 18:11:03
|
when you construct a derived class, the parent class is fully constructed first, then the derived class is constructed. in this case, the baseclass constructor requires three arguments. in order for the baseclass to be constructed properly, it needs to receive its arguments immediately. the colon begins what is called a function preamble. This allows you to construct base classes and initialize constant data members before performing the body of your constructor. all this code really means to you is "before we construct our derived class, we need to construct the base class". the author of "C++ In Action" ( http://www.relisoft.com/book/index.htm) <http://www.relisoft.com/book/index.htm)> makes extensive use of function preambles for setting variables and whatnot. -----Original Message----- From: softnasolutions-ltd.fsbusiness.co.uk [mailto:so...@so...] Sent: Monday, June 25, 2001 10:54 AM To: dev...@li... Subject: [Dev-C++] Derived class initialization Hi all, I'm stuying C++ using some sample programs and I have come accross this line of code which i don't quite understand. PLease sombody tell me what it means. derivedclass::derivedclass(classgrade *ave, name, age) : baseclass(ave, name, age). What i don't understand is what it means to have :baseclass(ave, name, age). I figure it has something to do with initiallising the derived calss. but i don't understant exactly what it does. Thnx. Napoleon. "The sender believes that this E-mail and any attachments were free of any virus, worm, Trojan horse, and/or malicious code when sent. This message and its attachments could have been infected during transmission. By reading the message and opening any attachments, the recipient accepts full responsibility for taking protective and remedial action about viruses and other defects. The sender's employer is not liable for any loss or damage arising in any way from this message or its attachments." |