1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
class Base
{
public:
Base(int x, int y, int z)
{
// do stuff with x, y, z
}
};
class Derived : public Base
{
public:
// Derived(int m) // <- bad, it has to take 4 params, not 1
Derived(int x, int y, int z, int m) // <- good, takes 4 params
: Base(x,y,z) // <- pass the first 3 to Base's ctor
{
// do something with m
}
};
int main()
{
int x=0,y=1,z=2,m=3;
Derived(x, y, z, m); // now this works
}
|