LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

Rep: Reputation: 0
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)
 
Old 08-28-2008, 07:18 AM   #2
kerenLinuxForum
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
 
  


Reply



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 03:11 AM
const/static members in classes lucky6969b Programming 2 03-27-2006 05:43 PM
C++: #define OR const int ? Hady Programming 5 10-07-2005 11:43 AM
global const int X = DEFINED (shows value in debugger?) abs Programming 2 09-25-2004 11:09 AM
c++ ERROR: int to const char ashirazi Programming 6 08-06-2004 10:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:46 PM.

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