Reputation: 73
I want to initialize transform variable when creating theGameObject, but something is going wrong. Compiler says:
C3646 'transform' : unknown override specifier (line 4)
C4430 missing type specifier - int assumed. Note: C++ does not support default-int (line 4)
C3861 'Transform': identifier not found (line 5)
C2614 'GameObject' : illegal member initialization: 'transform' is not a base or member (line 5)
1. class GameObject
2. {
3. public:
4. Transform transform;
5. GameObject() : transform(Transform()) {}
6. };
7.
8. class Transform
9. {
10. public:
11. Vector3 position;
12. Vector3 rotation;
13. Vector3 dimension;
14.
15. Transform()
16. {
17. position = Vector3();
18. rotation = Vector3();
19. dimension = Vector3();
20. }
21. }
In main.cpp I call:
GameObject theGameObject = GameObject();
What I've done wrong?
Upvotes: 0
Views: 77
Reputation: 36503
In your GameObject
class you have a Transform
object Transform transform;
but the compiler hasn't seen the Transform
class yet and thus it doesn't know it's size or what it even is. You should define Transform
and then GameObject
instead of GameObject
and then Transform
. You probably want to seperate these classes in individual header files too.
Side note:
You can just do GameObject theGameObject;
too.
Upvotes: 1