If I have the following code (simplified version of the problem):
class TestA
{
public:
int A,B,C;
TestA(){A = 1; B = 5; C = 10;}
};
//This is a referencing class to allow for universal and consistent operations
class TestB
{
public:
int &A, &B, &C; //Note references
TestB(TestA &A) : A(A.A), B(A.B), C(A.C){}; //This is fine
TestB(TestC &C) : A(C.A), B(C.B), C(C.C){}; //This needs to be prototyped
};
//Similar class to TestA but in the main program would have...
//...many different and conflicting variables and has to be treated as stand alone
class TestC
{
public:
int A, B, C;
int Size;
void Function()
{
TestB B(*this); //This uses TestB. TestB cannot be prototyped.
//etc etc
}
};
I want to know, is it possible to prototype initialiser list based constructors?
If not, what is the alternative? Bear in mind references have to be immediately initialised.
If by “prototyping” you mean separation of function declaration and definition, this should work: