Linker error: tried to make basic cpp program but there is a linker error saying:unresolved symbol "private: static int complex::count". When i removed the static words, its working fine.
Asked
Active
Viewed 106 times
0
Barmar
- 741,623
- 53
- 500
- 612
Durvesh Navande
- 1
- 2
-
Share your code here. – Onic Team Jul 29 '17 at 05:11
-
Post your code as plain text, not an image. See https://stackoverflow.com/help/formatting for code formatting help. – Barmar Jul 29 '17 at 05:11
-
Also you'd better write a deconstructor that decreases `count` by 1. – iBug Jul 29 '17 at 09:18
1 Answers
0
you must explicitly define your static variable outside of the class. For example like this:
class complex {
....
int static count;
....
};
// initialization
int complex::count = 0;
iskakoff
- 98
- 1
- 4
