I am working on developing an operating kernel from the scratch. I set the development environment on Linux. After all of the Low Level Programming in Assembly language, now i am working in C++. I have managed the task in different modules. There is a problem to me. I will expalin the generic form of my problem. i have created three files in a in the same directory.
1) main.cpp
2) myclass.h
3) myclass.cpp
// main.cpp
#include<iostream>
#include"myclass.h"
using namespace std;
int main()
{
myclass a;
return 0;
}
//myclass.h
#ifndef MYCLASS_H
#define MYCLASS_H
class myclass
{
public:
myclass();
};
#endif
// myclass.cpp
#include<iostream>
#include"myclass.h"
using namespace std;
myclass :: myclass()
{
cout<<"Constructer";
}
when i compile main.cpp it shows:
/tmp/ccm50K0J.o: In function
main': main.cpp:(.text+0x10): undefined reference to
myclass::myclass()' collect2: error: ld returned 1 exit status
But when i put the function definition in the header file it works. Thanks in Advance ..............