typedef struct constructor
-
If I define the constructor of typedef struct, it will appear some error(error C4430,errorC4183). How do I solve this problem?
struct b
{b() { } b(int p1) { m\_p1=p1; } int m\_p1;
};
typedef struct
{a() { } a(int p1) { m\_p1=p1; } int m\_p1;
}a;
1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(156) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(158) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int' 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(161) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(163) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int'
-
If I define the constructor of typedef struct, it will appear some error(error C4430,errorC4183). How do I solve this problem?
struct b
{b() { } b(int p1) { m\_p1=p1; } int m\_p1;
};
typedef struct
{a() { } a(int p1) { m\_p1=p1; } int m\_p1;
}a;
1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(156) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(158) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int' 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(161) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(163) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int'
the type was named but struct wasn't.
typedef struct a
{
a()
{
}a(int p1) { m\_p1=p1; } int m\_p1;
} aType;