C++ syntax of constructors " 'Object1 a (1, Object1(2))''
- by osgx
Hello
I have a such syntax in program
class Object1 : BaseClass {
BaseClass *link;
int i;
public:
Object1(int a){i=a;}
Object1(int a, Object1 /*place1*/ o) {i=a; link= &o;}
};
int main(){
Object1 a(1, /*place2*/ Object1(2));
...
}
What do I need in place1? I want to save a link (pointer) to the second object in the first object. Should I use in place1 reference "&"?
What type will have "Object1(2)" in place2? Is it a constructor of the anonymous object? Will it have a "auto" storage type?