I have a main c++ file, for example called a.cpp
I also have two other files, b.h and b.cpp and a.cpp includes b.h
a.cpp
b.h
b.cpp
Please could someone explain why when I compile a.cpp I get the error "Undefined Symbols"
referring to
If I try to do exactly the same in the b.cpp I don't have any problems, why is a.cpp unable to use the class from b.h which is defined in b.cpp?
regards
I also have two other files, b.h and b.cpp and a.cpp includes b.h
a.cpp
Code:
#include "b.h"
using namespace std;
int main() {
TestClass test (100);
return 0;
}
b.h
Code:
class TestClass {
public:
int value;
TestClass();
TestClass(int new_value);
}
b.cpp
Code:
#include "b.h"
TestClass::TestClass() {
value = 0;
}
TestClass::TestClass(int new_value) {
value = new_value;
}
Please could someone explain why when I compile a.cpp I get the error "Undefined Symbols"
referring to
Code:
TestClass(int)
If I try to do exactly the same in the b.cpp I don't have any problems, why is a.cpp unable to use the class from b.h which is defined in b.cpp?
regards
Last edited: