Static classes C ++

Static classes C ++

本文关键字:classes Static      更新时间:2023-10-16
 #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

请在此处查看实时编译器示例。