Maybe I'm just asking badly my question to Google, but I don't find an answer to my problem. My trouble is that my inherited constructor calls my default base constructor and I don't really get why. Here are my simplified version.
Example:
A.cpp
#include <iostream>
#include "A.h"
using namespace std;
A::A()
{
cout << "A" << endl;
}
B.cpp
#include <iostream>
#include "B.h"
using namespace std;
B::B()
{
cout << "B" << endl;
}
B::B(int x)
{
cout << "B" << x << endl;
}
Source.cpp
#include <iostream>
#include "A.h"
#include "B.h"
using namespace std;
int main() {
B * b = new B();
cout << "---" << endl;
B * b2 = new B(2);
system("PAUSE");
return 0;
}
Output:
A
B
---
A
B2
Press any key to continue . . .
I just want to see what B constructor do. Like this:
B
---
B2
Press any key to continue . . .