结构体,作为成员函数的返回,报错!
结构体定义有:
...头文件前面部分我省略了.
public:
typedef struct wxw
{
CString name;
int year;
} WXW;
WXW Test();//成员函数
...前面部份CPP文件省略了:
WXW CMFCTestApp::Test()
{
WXW aa;
AfxMessageBox("testing...");
return aa;
}
//报告错误如下:
--------------------Configuration: MFCTest - Win32 Debug--------------------
Compiling...
MFCTest.cpp
D:\code_cpp\MFCTest\MFCTest.cpp(105) : error C2143: syntax error : missing ';' before 'tag::id'
D:\code_cpp\MFCTest\MFCTest.cpp(105) : error C2501: 'WXW' : missing storage-class or type specifiers
D:\code_cpp\MFCTest\MFCTest.cpp(105) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
MFCTest.exe - 1 error(s), 0 warning(s)
很是郁闷!不是知道哪里有问题.