2011-02-05 11 views
0

私はいくつか入力して印刷戻ってそれを取る基本的なプログラムを作っていますが、私は私の静的variable.Pleaseについての奇妙なエラーを取得していますがout.Thanks私を助け文字列静的メンバエラー

コード:

​​

エラー:

------ Build started: Project: new, Configuration: Debug Win32 ------ 
Compiling... 
program.cpp 
c:\documents and settings\1\my documents\visual studio 2008\projects\new\new\program.cpp(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
Build log was saved at "file://c:\Documents and Settings\1\My Documents\Visual Studio 2008\Projects\new\new\Debug\BuildLog.htm" 
new - 1 error(s), 0 warning(s) 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 
? 

答えて

2


ソリューション:含まれています<cstdlib>

問題2)静的メンバーcountは宣言されていますが、定義されていません。
解決方法:メンバーをstatic int countの代わりにint Persons::count;と定義してください。

1
あなたも int Persons::count;として静的変数を定義する必要が

、あなたのgetData & displayData構文が間違っています。 .演算子の代わりに->演算子を使用する必要があります。代わりに

int Persons::count; 
2

あなたのプログラムは二つの問題

問題なし1)exit(1);ための欠落宣言が

static int count;//initializing the static member 

書き込みの

+0

プログラムはヘッダーを含めずに動作します。:S –

+0

@fahad:そうではありません。 –

関連する問題