我收到編譯C++類的錯誤,它涉及將從方法返回的Struct。我已經將代碼分解到最低限度,並仍然得到錯誤。我正在使用Visual Studio 6.0。在C++類中導致編譯錯誤的結構
代碼
// TestClass.cpp: implementation of the TestClass class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TestClass.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
TestClass::TestClass()
{
}
TestClass::~TestClass()
{
}
ProductInfo TestClass::GetProdInfo()
{
ProductInfo PI;
return PI;
}
// TestClass.h: interface for the TestClass class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TestClass_H__081E411D_44F9_4E0B_9FE7_CF6F708BE769__INCLUDED_)
#define AFX_TestClass_H__081E411D_44F9_4E0B_9FE7_CF6F708BE769__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class TestClass
{
public:
struct ProductInfo
{
char cCode;
char cItem[20];
long lValue;
};
public:
TestClass();
virtual ~TestClass();
private:
ProductInfo GetProdInfo();
};
#endif // !defined(AFX_TestClass_H__081E411D_44F9_4E0B_9FE7_CF6F708BE769__INCLUDED_)
收到的錯誤
Compiling...
TestClass.cpp
C:\Work\TestStruct\TestClass.cpp(22) : error C2143: syntax error : missing ';' before 'tag::id'
C:\Work\TestStruct\TestClass.cpp(22) : error C2501: 'ProductInfo' : missing storage-class or type specifiers
C:\Work\TestStruct\TestClass.cpp(22) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
TestStruct.exe - 3 error(s), 0 warning(s)
任何想法,爲什麼我得到這些錯誤?
感謝
輝煌,感謝隊友的返回類型。我知道我錯過了簡單的事情。 –
完成,正在等待所需的5分鐘才能接受 –