S
subramanian100in
Consider the following piece of code stored in a file called x.cpp
class Test;
extern void fn_one(Test t);
extern Test fn_two();
Test fn_three(const Test &obj)
{
fn_one(obj);
return fn_two();
}
Suppose I compile(only compile , not link) this program. I am getting
compilation error saying undefined use of class Test.
I do not understand why we cannot use a forward declared class in the
definition of a function but use it only in the function declaration.
Kindly explain
Thanks
V.Subramanian
class Test;
extern void fn_one(Test t);
extern Test fn_two();
Test fn_three(const Test &obj)
{
fn_one(obj);
return fn_two();
}
Suppose I compile(only compile , not link) this program. I am getting
compilation error saying undefined use of class Test.
I do not understand why we cannot use a forward declared class in the
definition of a function but use it only in the function declaration.
Kindly explain
Thanks
V.Subramanian