Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
作成したすべてのクラスからアクセスできる変数を作成したいと考えています。どうすればいいですか?メインウィンドウのヘッダーファイルに次のように記述してみました:
public: extern int number;
そして、次のように言って、他のクラスでこれを参照します。
MainWindow::number;
これによりエラーが発生します: エラー: 'number' に指定されたストレージ クラス。誰かが私が間違っていることを言うことができますか?
成功のキーワードはstatic. 静的変数にします。
static