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