Class Deriving

I am a bit inexpert with classes when it comes to Constructors.
My problem is this:
I create a GeneralClass class, and create a DerivedClass, derived from GeneralClass.
How should i correctly call GeneralClass's constructor from DerivedClass's constructor?

Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class GeneralClass {
  public:
	GeneralClass() {
		printf("GeneralClass constructor called.");
		// My own GeneralClass constructor here
	}
};
class DerivedClass : public GeneralClass {
  public:
	DerivedClass() {
		// GeneralClass's Constructor Here
		printf("DerivedClass constructor called.");
		// My own DerivedClass constructor here
	}
};
Have you run that example? If you don't specify it yourself, the default constructor is called. Otherwise you can do this:
1
2
3
4
MyClass() : MyMember(blah), MyBaseClass(bleh) /*rest are default-constructed*/
{
    //meh
}
If you don't specify it yourself, the default constructor is called.

I need to specify both constructors...
Anyways, that could be what i need. Thanks for your answer, anyways, I hope it is going to work (Probably yes).
Topic archived. No new replies allowed.