LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Linking error. static const int (http://www.linuxquestions.org/questions/linux-software-2/linking-error-static-const-int-665992/)

kerenLinuxForum 08-28-2008 03:49 AM

Linking error. static const int
 
Hello.
I have a linking error when using 'static const int';

My code
1.class A
2.{
3. static const int b= 5;
4.};
5. const int A::b;

The code is compile, but i receive a linking error:
multiple definitions of A::b.

if I remove the definition of b outside the class( remove line 5) i receive a linking error :
reference to undefined ....
(the code works in VS without line number 5)

kerenLinuxForum 08-28-2008 07:18 AM

Problem solved. the problem was that i put the decleration (line 5) in the .h file rather than the .cpp file


All times are GMT -5. The time now is 01:36 AM.