Reputation: 2252
Why the function bellow void i( )
is not called as in a 'Normal' function.
void i(){
cout << 10 << endl;
}
int main(){
class i {
int j;
};
i();//
return 0;
}
The normal behavior expected is to print 1O, but I did not getting anything, not a compiler warning nor the result.
Upvotes: 1
Views: 98
Reputation: 2908
The inner i
is shadowing the outer one. You are calling the default constructor of class i which does nothing in this case.
The solution is to explicitly scope the call, as ::i();
Upvotes: 8
Reputation: 2179
Because it's trying to call "i" in the current scope:
You can call your function::i()
;
Upvotes: 1