私は C++ が初めてで、MS Visual C++ でシングル ドキュメント インターフェイス アプリケーションを作成しました。コンパイルすると、Day10 SDIDOC.h というヘッダファイルに以下のようなエラーが発生しました。
error C2143: syntax error : missing ';' before '*'
error C2501: 'CLine' : missing storage-class or type specifiers
error C2501: 'GetLine' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '*'
error C2501: 'CLine' : missing storage-class or type specifiers
error C2501: 'AddLine' : missing storage-class or type specifiers
私のファイルは
Day10 SDIDOC.h
public:
CLine * GetLine(int nIndex);
int GetLineCount();
CLine * AddLine(CPoint ptFrom,CPoint ptTo);
CObArray m_oaLines;
virtual ~CDay10SDIDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
これらの GetLine() および AddLine() メソッドは、Day10 SDIDOC.cpp で次のように実装されます。
Day10 SDIDOC.cpp
CLine * CDay10SDIDoc::AddLine(CPoint ptFrom, CPoint ptTo)
{
//create a new CLine Object
CLine *pLine = new CLine(ptFrom,ptTo);
try
{
//Add the new line to the object array
m_oaLines.Add(pLine);
//Mark the document as dirty(unsaved)
SetModifiedFlag();
}
//Did we run into a memory exception ?
catch(CMemoryException* perr)
{
//Display a message for the user,giving the bad new
AfxMessageBox("Out of Memory",MB_ICONSTOP|MB_OK);
//Did we create a line object?
if(pLine)
{
//Delete it
delete pLine;
pLine = NULL;
}
//delete the exception object
perr->Delete();
}
return pLine;
}
そしてGetLineメソッド
CLine * CDay10SDIDoc::GetLine(int nIndex)
{
return (CLine*) m_oaLines[nIndex];
}
何が悪いのか理解できません。その解決策を教えてください。ありがとうございました...