Sorry, my first post on this forum is a question, but I'm pretty confused about this.

There's a few steps in my question, and I'm confused about several. So, here we go:

baseClass *base;
derivedClass *derived;

base = (derivedClass *) malloc(sizeof(derived));
memcpy(base, derived, sizeof(derived);

Would the memcpy statement work? Would base actually contain all the variables that derived has?

Let's consider that this works. So now, base is actually a derived class object. How would I call a function of derivedClass on base?

base->derivedClassFunction() doesn't work.

Thanks in advance :)

Ah, I figured it out.

This would work:

((derivedClass *) derivedObj)->derivedFunction