When I declare an object I have to do this. Class object;
However this actually calls the constructor of the object, and results in an error if the constructor needs to take parameters. What is the correct way of declaring an object without defining it in a .h?
Asked
Active
Viewed 98 times
0

w4etwetewtwet
- 1,330
- 2
- 10
- 20
-
1`extern Class object;` – R. Martinho Fernandes Jul 28 '13 at 08:17
1 Answers
1
If you just want to declare an object, not define an object, you should use the keyword "extern":
extern YourClass yourObject;
the statement above can be placed either in .h or .cpp without any problem.

nicky_zs
- 3,633
- 1
- 18
- 26