Why the code is not causing compile error?
#include<iostream>
class x{
private:
int v;
public:
x():v(7){};
};
class b{
private:
static x as;
int a;
public:
b():a(8){};
};
//x b::as;
int main(){
b g;
return 0;
}
Even after commenting the particular line x b::as code works which I think it should as I haven't define/initiate my static object which is necessary. Why is it so?
And what if I initiate non-static object using static object like static x asd; x bv=asd; ?
Aucun commentaire:
Enregistrer un commentaire