D
doublemaster007
1) Can the unions and structures be inherited?
2) Can Unions and structures have virtual function?
2) Can Unions and structures have virtual function?
1) Can the unions and structures be inherited?
2) Can Unions and structures have virtual function?
Kai-Uwe Bux said:unions: no (and they cannot inherit either)
structs: yes (and they can inherit, too)
unions: no
structs: yes
I think that you can even pre-declare a type as a struct and implement
it as a class, and it will work at least in some compilers. I don't
know, however, if that's standard behavior. (Is it?)
As an additional note, there's basically no difference between a
struct and a class in C++, except that in a struct all members are
public by default while in a class they are private by default (ie. when
there's no explicit "public:" or "private:" specifier).
I think that you can even pre-declare a type as a struct and implement
it as a class, and it will work at least in some compilers. I don't
know, however, if that's standard behavior. (Is it?)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.