K
Kiel
=====
My error is:
error C2512: no appropriate default constructor available
I'm trying to use the default args for class B when it is an aggregate
of class A. I could solve this problem with a point to B and
initialize it in the C'tor of A, but logically it makes sense as an
aggregate.
=====
Sample Code:
---- main.cpp ---
int main()
{
A foo; // <-- compiler error here
}
---- B.h ---
class B
{
public:
B();
// more stuff
protected:
m_number;
}
--- B.cpp ---
B:B(int num = 1) m_number(num)
{
// empty
}
--- A.h ---
class A
{
public:
A();
// more stuff
protected:
B obj;
}
--- A.cpp ---
A::A()
{
// empty
}
My error is:
error C2512: no appropriate default constructor available
I'm trying to use the default args for class B when it is an aggregate
of class A. I could solve this problem with a point to B and
initialize it in the C'tor of A, but logically it makes sense as an
aggregate.
=====
Sample Code:
---- main.cpp ---
int main()
{
A foo; // <-- compiler error here
}
---- B.h ---
class B
{
public:
B();
// more stuff
protected:
m_number;
}
--- B.cpp ---
B:B(int num = 1) m_number(num)
{
// empty
}
--- A.h ---
class A
{
public:
A();
// more stuff
protected:
B obj;
}
--- A.cpp ---
A::A()
{
// empty
}