Reputation: 1031
In my c++ application I have aaa.h file which has this definition in it:
typedef struct
{
int a;
int b;
} CCC;
typedef struct _DDD
{
unsigned int e;
CCC cccArray[100];
} DDD;
in my aaa.cpp I write:
#include "aaa.h"
DDD * dddPtr
but then I got this error: Error c2061: syntax error: identifier 'DDD'
can you please help with this issue?
thanks
Upvotes: 0
Views: 961
Reputation: 967
First thing: you should terminate the declaration with a semicolon ;
.
Second: In your case, there is no need for typedef
s in C++, just define class
es or struct
ures:
struct CCC
{
int a;
int b;
};
struct DDD
{
unsigned int e;
CCC cccArray[100];
};
int main()
{
DDD * dddPtr;
}
EDIT: Moreover, you should make sure that each member is properly initialized by providing suitable constructors for CCC
and DDD
.
Upvotes: 1
Reputation: 26279
For C++ you don't need that typedef
'ed struct
- just do this:
struct CCC
{
int a;
int b;
};
struct DDD
{
unsigned int e;
CCC cccArray[100];
};
and this:
#include "aaa.h"
DDD * dddPtr = NULL; // or = new DDD;
Upvotes: 1