Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-28-2008, 04:49 AM   #1
LQ Newbie
Registered: Aug 2008
Posts: 15

Rep: Reputation: 0
Linking error. static const int

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

My code
1.class A
3. static const int b= 5;
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)
Old 08-28-2008, 08:18 AM   #2
LQ Newbie
Registered: Aug 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Problem solved. the problem was that i put the decleration (line 5) in the .h file rather than the .cpp file


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
global static const - c++ emarri Programming 5 09-07-2006 04:11 AM
const/static members in classes lucky6969b Programming 2 03-27-2006 06:43 PM
C++: #define OR const int ? Hady Programming 5 10-07-2005 12:43 PM
global const int X = DEFINED (shows value in debugger?) abs Programming 2 09-25-2004 12:09 PM
c++ ERROR: int to const char ashirazi Programming 6 08-06-2004 11:01 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:10 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration