S
spipyeah
My compiler is known not to be very compliant. So I can't base myself
on the fact that the following doesn't work to determine whether or
not it is legal C++.
In an initializer list, can you pass objects as parameters (by
reference or otherwise) to other objects constructed later in the
initializer list?
Example:
class Obj
{
public:
Obj( int a ) {};
};
class ObjConsumer
{
public:
ObjConsumer( Obj &first_obj, Obj &second_obj ) {};
};
class myclass
{
public:
myclass();
protected:
Obj obj1, obj2;
ObjConsumer consumer;
};
myclass::myclass() :
obj1(5),
obj2(7),
consumer( obj1, obj2 )
{
}
on the fact that the following doesn't work to determine whether or
not it is legal C++.
In an initializer list, can you pass objects as parameters (by
reference or otherwise) to other objects constructed later in the
initializer list?
Example:
class Obj
{
public:
Obj( int a ) {};
};
class ObjConsumer
{
public:
ObjConsumer( Obj &first_obj, Obj &second_obj ) {};
};
class myclass
{
public:
myclass();
protected:
Obj obj1, obj2;
ObjConsumer consumer;
};
myclass::myclass() :
obj1(5),
obj2(7),
consumer( obj1, obj2 )
{
}