If I have a class:
class A
{
private:
char z;
int x;
public:
A(char inputz, int inputx);
~A() {}
}
I want to make an array of A in class B.
class B
{
private:
A arrayofa[26];
public:
B();
~B() {}
void updatearray(); // This will fill the array with what is needed.
}
class B
{
B:B()
{
updatearray();
std::sort( &arrayofa[0], &arrayofa[26], A::descend );
}
}
How do I explicitly initialize arrayofa in the constructor of B?
The default constructor will be called automatically (for non-POD). If you need a different constructor you’re out of luck, but you can use
vectorinstead which will support what you need.