hi im trying to figure out how to make this work
i have main.cpp, asd2.cpp and asd.h
asd.h has the class inside
here is the code
Code:
class a {
int x;
public:
int getX();
void setX(int);
};
asd2.cpp has some functions from class a
Code:
#include <iostream>
#include "asd.h"
void a::setX(int b){
x = b;
}
int a::getX(){
return x;
}
and finally here is the main
Code:
#include <iostream>
#include "asd.h"
using namespace std;
int main(void){
a b;
b.setX(109);
cout<<b.getX();
cin.get();
return 0;
}
im wondering why it doesnt work, it says
Code:
[Linker error] undefined reference to `a::setX(int)'
[Linker error] undefined reference to `a::getX()'
ld returned 1 exit status
i think it has something to do with the "include"
does anyone know how to fix this problem? thanks in advance