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.
私のコードは次のとおりです
#include <vector> using namespace std; ... class A { NEW_TYPE a; ... public: typedef vector<int> NEW_TYPE; ... }
エラーは、「NEW_TYPE」はタイプに名前を付けていないことを示しています
誰が何が問題なのか知っていますか?
ありがとう
一般に、C++ の名前は、宣言された後にのみ使用できます。
typedef int foo; foo x = 1; // OK bar y = 2; // Error typedef int bar; // too late
同じことがあなたのクラスにも当てはまります。typedef を上に移動します。
class A { public: typedef std::vector<int> NEW_TYPE; private: NEW_TYPE a; // ... public: // ... };