I'm in doubt on how to make object initialization without a default constructor on the superclass.
#include <iostream>
class A
{
protected:
A(std::string title, int xpos, int ypos);
};
class B : A
{
protected:
//Is that correct?
A* m_pA(std::string title, int xpos, int ypos);
//Why not just A* m_pA;?
public:
B(std::string title, int xpos, int ypos);
};
B::B(std::string title, int xpos, int ypos) : m_pA(title, xpos, ypos)
{
//does nothing yet.
}
As you can see I'm trying to initialize the m_pA
object of type A
in the constructor of B, the VC is throwing me:
"m_pA" is not a nonstatic data member or base class of class "B"
You can see the example compiled and the errors here.
I want to know why and how initialize a member object of a class without the default constructor, and why I am wrong.
Thanks in advance!