when i compile, it gives the following error :
Undefined first referenced
symbol in file
main /auto/usc/gnu/gcc/4.2.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.2.1/crt1.o
ld: fatal: Symbol referencing errors. No output written to a
collect2: ld returned 1 exit status
Can anyone please tell as to what's going wrong here.
I have some code where i want to have one class keeping the data members and the other
having a member function and another having the main in it. I have made a prototype
of what i want to do for simplicity.
#include <stdio.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
class M
{
public:
int value1;
int value2;
};
class P
{
public:
int sum(M n){
int t = 2;
int s = n.value2 + t;
return s;
}
};
class N
{
int main(){
M m;
P p;
m.value1 = 1;
m.value2 = 2;
int res = p.sum(m);
cout << "sum is" << res;
}
};