Access other class member function

Hey.. I got in trouble here...

I'm trying to do this:
fileA.hpp
1
2
3
4
5
extern class A {
public:
int functionA(void);
friend class B;
} objectA;


file2.cpp
1
2
3
4
5
#include <file1.hpp>
#include <file2.hpp>
void objectA.functionB(void) {
objectA.functionA(); // here is my problem.
}


mainFile.cpp
1
2
3
4
5
6
7
8
9
10
#include <file1.hpp>
#include <file2.hpp>
int main() {
classB myclassB;

objectA.functionA();
myclassB.functionB();

return 0;
}


Let me explain:
classes A and B are part of a static library project.
I need to test it using another project (where "mainFile.cpp" is).

I don't understand what is happening, what i'm doing wrong...
when I try to compile the tester project (executable) i get "undefined reference to 'objectA' at file2.cpp, 3rd line.

How should i proceed??
what are my mistakes?

what is the best alternative to handle this?

Please and thank you!
in fileA.hpp you declare a gobal variable 'objectA' which must be defined somewhere in your cpp files.

in file2.cpp: line 3 doesn't make sense. You can define a function for a class (i.e. void A::functionB(void) {, but nor for an object/variable
Topic archived. No new replies allowed.