Consider following two programs.
p1.cpp
#include <iostream>
struct test
{
void fun();
};
int main()
{
test t;
t.fun();
}
p2.cpp
#include <iostream>
void test::fun()
{
std::cout<<"fun() is called\n";
}
I am compiling like following.
g++ -c -o p1.o p1.cpp
g++ -c -o p2.o p2.cpp <--------- This gives me compiler error.
How can I solve this error? What I am doing wrong?