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

Recommended Answers

All 2 Replies

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)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.