about three layered c++ program

i am trying to make a simple 3 layered c++ program
consist of header.h, main.cpp & imp.cpp

in header.h:

#include <iostream>
using namespace std;
class a{
int x;
public:
void set(int );
void get(int &);
};

------------------------------------------

in imp.cpp

#include "header.h"
void a::set(int g){
x=g;
}
void a::get(int &b){
b=x;
}
-------------------------------------------

in main.h

#include "header.h"
int main (){
a ah;
int b;
ah.set(19);
ah.get(b);
cout<<b<<endl;
return 1;
}

-------------------------------------------

iam sure that it does work on microsoft visual studio but i am running linux / ubuntu distro , so i am using GNU
so when i try to compile it

g++ main.cpp -o tt
i get this
/tmp/ccGOzqaA.o: In function `main':
main.cpp:(.text+0x7c): undefined reference to `a::set(int)'
main.cpp:(.text+0x8e): undefined reference to `a::get(int&)'
collect2: ld returned 1 exit status

so any ideas ???
Those aren't layers. They are called "files".

Anyway, you're not linking all the files.
Try this command line:
g++ main.cpp imp.cpp -o tt
works for me :D
i know these are file dude but it is called the three layered code , which means that you use main, imp and header files.

thank you :D now i get no errors
No, these aren't layers. There are three files, two compiled modules, one program.
Topic archived. No new replies allowed.