linking error

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2006
Posts: 7
Reputation: ridhimasatam is an unknown quantity at this point 
Solved Threads: 0
ridhimasatam ridhimasatam is offline Offline
Newbie Poster

linking error

 
0
  #1
Jun 25th, 2007
hi,
if i hav member variables of a say class A defined and initialized in a class A how do i access its variables in a classB which is in diff file
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: linking error

 
0
  #2
Jun 25th, 2007
Usually you are supposed to have 2 files per class.
Header file: ClassName.h, which declares the class interface.
Source file: ClassName.cxx/cpp/.. which defines the class. I.e. has implementation for the class's interface.

Assuming you have A.h and A.cpp, to use A's variables in another class B, you'll have to #include "A.h" in B.cpp (or B.h depending on need)
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: linking error

 
0
  #3
Jun 25th, 2007
Oh ! Now I see the subject of the post.
If you are facing linking problems then get back with some more info as to how have you organized your code, in case you are using shared objects or DLLs things would be a li'l different.
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 747 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC