Hi, here is the code
Code:
struct Base {
	int mem1;
};

struct A : Base {
	int mem2;
};

struct B : Base {
	int mem3[10];
};

void fun(Base& base) {
	cout << sizeof(base) << " ";
};

void main() {
	Base base; A a; B b;
	cout << sizeof(base) << "  " << sizeof(a) << "  " << sizeof(b) << endl;
	fun(base); fun(a); fun(b);
};
the sizeof in main() worked well, but not after the object is passed into the function fun().

actually, I am trying to write a fun() that can take the base class (Base) object or any derived classes (A, B) objects and prints the correct size of the pass in object, which I failed in the above code.

Any help? Thank you very much!