![]() |
| | #1 |
| Registered User Join Date: Jan 2008
Posts: 540
| class call to constructor class B and C inherits from A, class D inherit from B and C. A has a variable that is declared as public called count. D calls the non-default constructor of it's of the ancestor |
| -EquinoX- is online now | |
| | #2 | |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| Quote:
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot | |
| brewbuck is offline | |
| | #3 |
| 3735928559 Join Date: Mar 2008
Posts: 662
| it means that D passes an argument in its constructor calls to its ancestors. e.g: Code: class A
{
public:
int count;
A():count(0){} // <- default constructor (no arguments passed)
A(int _count):count(_count){} // <- non default constructor
};
class B : public A
{
B():A(){}
B(int _count):A(_count){}
};
class C : public A
{
C():A(){}
C(int _count):A(_count){}
};
class D : public B,public C
{
public:
D(): B(1), C(2) {}
}
Last edited by m37h0d; 11-04-2009 at 07:37 AM. Reason: accidental premature submission |
| m37h0d is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| temperature sensors | danko | C Programming | 22 | 07-10-2007 07:26 PM |
| Class won't call | Aalmaron | C++ Programming | 3 | 04-13-2006 04:57 PM |
| Having a class function call a function outside the class | Aeroren | C++ Programming | 2 | 08-09-2005 06:33 AM |
| My Window Class | Epo | Game Programming | 2 | 07-10-2005 02:33 PM |
| gcc problem | bjdea1 | Linux Programming | 13 | 04-29-2002 06:51 PM |