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;
 }

Please tell me, what do "static" in class declaration?

Upvotes: 0

Views: 1374

Answers (1)

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

"Please tell me, what do "static" in class declaration? Thank."

It actually does nothing, but is ignored by the compiler (with VS 2013 only as it seems). There's a warning issued about this:

source_file.cpp(9) : warning C4091: 'static ' : 
   ignored on left of 'base' when no variable is declared

See the live compiler sample here please.

Upvotes: 4

Related Questions