| Shiro (3) | |||
|
im trying to acess parent class properties from inner class... but seems nor working eg:
its possible do it? | |||
|
|
|||
| Peter87 (3672) | |
| What do you mean by "not working"? Do you get an error message? | |
|
|
|
| kevinkjt2000 (224) | |
| Probably need to put a semicolon at the end of both class declarations, and remove the extraneous semicolon on line 9. | |
|
|
|
| Shiro (3) | |||
|
Visual Studio 2012 show this error error C2512: 'Parent' : no appropriate default constructor available fullcode
| |||
|
|
|||
| Cubbi (1568) | |
|
You're attempting to default-construct an object of type Parent, confusingly called "Parent", at global scope To do that, Parent's default constructor is required. The compiler attempts to generate Parent's default constructor, which attempts to default-construct all members. Your class Parent has a data member confusingly called "Inner", of type Parent::Inner. The type Parent::Inner has a user-defined constructor which prevents generation of Inner's default constructor, which means Parent's default constructor cannot be compiled either, | |
|
|
|
| Shiro (3) | |
|
i imagined... well this means which isn't possible to access parent properties? there are another way? | |
|
Last edited on
|
|
| Cubbi (1568) | |
|
No, this means that you can't default-construct an object of a class whose default constructor you suppressed. The smallest change to make this compile is to add public: Inner() {} between lines 6 and 7
| |
|
|
|