#include<iostream>
using namespace std;
class Foo {
void Bar( void ) const ;
};
int main()
{
Foo f;
cout<<sizeof(f)<<endl;
}
I ran this on g++,it did not give me any compilation error. Also, it executed giving o/p 1 which is correct. But I was expecting, error during linking. Is this compiler dependent?
I can only imagine that you expected to get an error as Foo::Bar
is not defined. The One Definition Rule in the standard requires only that used elements are defined. In your particular case, nothing in your program uses Foo::Bar
, so the program does not need that definition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With