M
Mohammad Omer Nasir
Hi,
i made a structure in header file "commonstructs.h" is:
typedef struct A
{
int i;
A( )
{
i = 90;
}
} AA, * LPAA;
after I wrote structure code, i made a class with the name "CTemp",
which have a function with the name of fun1(AA *) and following code
was written in Temp.h Header file...
class CTemp
{
public:
void fun1( AA * temp);
};
and following code was written in Temp.cpp File...
#include "Temp.h"
#include "commonstructs.h"
void CTemp::fun1( AA * temp )
{
cout<<temp->i<<endl;
}
when i tried to write forward declaration code of structure A in
Temp.h header file which is
struct A;
class CTemp
{
public:
void fun1( AA * temp);
};
i compiled this code on vc++ 2k5 and it gives the following error:
error C2371: 'A' : redefinition; different basic types
error C2512: 'A' : no appropriate default constructor available
but if i write following line for forward declaration of struct A then
its work fine..
typedef struct A AA, *LPAA;
is the nature of structure A is change by making structure with
typedef??
Regards,
-aims
i made a structure in header file "commonstructs.h" is:
typedef struct A
{
int i;
A( )
{
i = 90;
}
} AA, * LPAA;
after I wrote structure code, i made a class with the name "CTemp",
which have a function with the name of fun1(AA *) and following code
was written in Temp.h Header file...
class CTemp
{
public:
void fun1( AA * temp);
};
and following code was written in Temp.cpp File...
#include "Temp.h"
#include "commonstructs.h"
void CTemp::fun1( AA * temp )
{
cout<<temp->i<<endl;
}
when i tried to write forward declaration code of structure A in
Temp.h header file which is
struct A;
class CTemp
{
public:
void fun1( AA * temp);
};
i compiled this code on vc++ 2k5 and it gives the following error:
error C2371: 'A' : redefinition; different basic types
error C2512: 'A' : no appropriate default constructor available
but if i write following line for forward declaration of struct A then
its work fine..
typedef struct A AA, *LPAA;
is the nature of structure A is change by making structure with
typedef??
Regards,
-aims