A
Anarki
#include <iostream>
using namespace std;
virtual class Class {
public:
void fun() { cout << "Class::fun" << endl; }
};
int main() {
Class objClass;
cout << "Size of Class = " << sizeof(objClass) << endl;
cout << "Address of Class = " << &objClass << endl;
return 0;
}
normal size of class with no variables is 1 if there is a virtual
function size will be 4, but here the scenario is different its a
virtual class instead of virtual function. The program compiled
successfully in Visual Studio 2005. I expected a vptr to be inserted
in it. instead nothing like that. size of Class was 1 instead of 4. Is
this some kind of Undefined Behaviour?
using namespace std;
virtual class Class {
public:
void fun() { cout << "Class::fun" << endl; }
};
int main() {
Class objClass;
cout << "Size of Class = " << sizeof(objClass) << endl;
cout << "Address of Class = " << &objClass << endl;
return 0;
}
normal size of class with no variables is 1 if there is a virtual
function size will be 4, but here the scenario is different its a
virtual class instead of virtual function. The program compiled
successfully in Visual Studio 2005. I expected a vptr to be inserted
in it. instead nothing like that. size of Class was 1 instead of 4. Is
this some kind of Undefined Behaviour?