Static classes C ++
Static classes C ++
#include"stdafx.h"
#include"iostream"
using namespace std;
static class base{
public:
int i = 3;
};
int main(){
base ob;
system("pause");
return 0;
}
请告诉我,类声明中的"静态"是什么?
">请告诉我,类声明中的"静态"是什么?谢谢。
它实际上什么都不做,但被编译器忽略(VS 2013 只是看起来(。对此发出了警告:
source_file.cpp(9) : warning C4091: 'static ' :
ignored on left of 'base' when no variable is declared
请在此处查看实时编译器示例。
相关文章:
- 为什么即使使用-cudart-static进行编译,库用户仍然需要链接到cuda运行时
- 如何处理 c++ 中类实现中的"invalid use of non-static data member"?
- 收到错误"invalid use of non-static data member 'stu::n' "
- LNK1104:无法打开libpjproject-i386-Win32-vc14-Debug-Static.lib
- 我应该在 C++ 中何时/为什么使用 STATIC?
- 在VS2019项目中集成ImageMagick:x64-windows-static library
- 如何处理Boost Spirit X3导致Visual Studio 2019 "static initialization order fiasco"?
- "static char __ = []() -> char"的含义
- 当初始值设定项是基类名时'initializer does not name a non-static data member or base class'错误
- Threads with Classes and std::packaged_task
- 无法在 DLL 中链接 SDL2-static.lib
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- C++线程"Call to non-static member function without an object argument"
- 出现这种错误的原因是什么"invalid use of non-static data member "
- static是如何使用ClassA::m_variable处理所有类对象的
- LNK2001:未解析的外部符号public:static类std::vector
- 使用-static libstdc++时std::线程弱,因此在运行时会导致崩溃
- 你能初始化unique_ptrs "static const vectors"吗?(C++17 与 GCC 7.3)
- Static classes C ++
- c++ classes and static