static-members

    1熱度

    2回答

    我想通過使用靜態函數來顯示類的對象和對象的數量。我輸入了這段代碼,但它不起作用。它給出了一個錯誤Too many types indeclaration" and "undefined symbol getCount。誰能幫我?這段代碼中的錯誤實際在哪裏? #include<iostream> #include<string> class Bag { private: stati

    5熱度

    1回答

    我在我的Android項目下面的代碼我開發使用「的IntelliJ IDEA」: Settings.Secure.putInt(this.getContentResolver(),Settings.Secure.ADB_ENABLED, 1); 我旁邊的這條線破發點,而當我停在這裏不幸的是我無法看到設置類的靜態字段。我曾嘗試過: Class g1 = Settings.class; 但是無

    0熱度

    2回答

    我很困惑編譯失敗和編譯失敗。如果我在Visual Studio中編寫一些代碼,那麼如果它報告生成失敗,那麼這也意味着編譯器在程序中發現了一些錯誤? 實際上,初始化靜態變量多次後,我得到了構建錯誤。 <code> int Child::count = 1; int Child::count = 2; </code> <code> 1>c:\users\muzammil\desktop\t

    1熱度

    3回答

    我試圖構造一個模板類靜態數據成員,當我嘗試編譯下面的代碼我收到此錯誤信息: |In instantiation of ‘T<int>& T<int>::t’:| 16|required from here| 16|error: explicit instantiation of ‘T<int>::t’ but no definition available [-fpermissive]| |

    4熱度

    4回答

    我很困惑爲什麼p->a()正在調用B::a()? C++文檔/標準中是否有一段描述了這種行爲? #include <iostream> using namespace std; class A { public: A() { cout << "A ctor" << endl; a_instance = this; } static A *get_instance

    -1熱度

    2回答

    我工作了整整一天,以C++方式獲得一些內聯到OOP。 這可能是一個愚蠢的問題,我想這只是我頭上的一個結或錯誤的設計,但也許你有一個想法該怎麼做。 我有一個「頂」類與指針數組到一大堆「子」類。 所有的「子」類都有一些計算要做,如果他們完成,他們必須給「頂」的反饋。所以我認爲簡單的使用一個靜態int「計算」 ,如果每個人都完成它是0.(否則它是例如1或5取決於還沒有計算多少「子」(例如,在加載新的原始

    1熱度

    2回答

    下面是一些代碼,引發NameError: class Foo: a = [1,2,3,4,5] b = all(i for i in a) # works fine ! c = [2,3,4] d = all(i in a for i in c) # raises NameError : name 'a' is not defined 我很迷茫由 - ;

    4熱度

    2回答

    我有簡單的代碼: #include <type_traits> class A { public: static int a; }; void a() {} int A::a = [](){static_assert(std::is_function<decltype(a)>::value,"'a' is not a function");return 777;}();

    0熱度

    2回答

    在下面的代碼中,你能告訴我爲什麼_myVar爲null,而g不是,當調用b.method()時? 我正在使用ActionScript3。 我錯過了什麼嗎? public Class A{ protected var _myVar:Type; protected method(){ _myVar // do something with _myVar...

    -1熱度

    2回答

    我有處理靜態私有變量的問題。這是我的代碼。 ClassA.h: class ClassA{ static int a; public: int getA(); }; Class.cpp: #include "ClassA.h" int ClassA::a = 9001; int ClassA::getA(){ return a; //<--- Unde