below is my program. I want to link the implementation file to main function.
// implementation file
// imp.cpp
#include "myClass.hpp"
#include <iostream>
using namespace std;
int display(void)
{
cout<<"hello"<<endl;
}
// main function
//main.cpp
#include "myClass.hpp"
int main()
{
myClass sub;
sub.display();
return 0;
}
// header file.
//myClass.hpp
class myClass
{
public:
void display();
};
I compiled it using this syntax:
1.) g++ -c main.cpp
2.) g++ -c imp.cpp
3.) g++ main.o imp.o -o main.exe
the error displayed was:
In function `main':main.cpp:(.text+0x23): undefined reference to `myClass::display()'
collect2: ld returned 1 exit status
What this means? how could i remedy this problem?
please help me...
tnx in advance..