Hi
Please look this code
Code:
// constructors and derived classes
#include <iostream>
using namespace std;
class mother {
public:
mother ()
{ cout << "mother: no parameters\n"; }
mother (int a)
{ cout << "mother: int parameter\n"; }
};
class daughter : public mother {
public:
daughter (int a)
{ cout << "daughter: int parameter\n\n"; }
};
class son : public mother {
public:
son (int a) : mother (a)
{ cout << "son: int parameter\n\n"; }
};
int main () {
daughter cynthia (0);
son daniel(0);
return 0;
}
If i change that part:
son (int a) : mother (a)
{ cout << "son: int parameter\n\n"; }
with this:
Code:
class son : public mother {
public:
son (int a): mother (a) ;
};
son::son(int a) : mother (a)
{ cout << "son: int parameter\n\n"; };
It gives error.
Can't i write son (int a): mother (a) ; while declaring it.
If i want to invoke base class conts. must i write when defining conts.?
Is this rule?
Thanks...