[gmpi] Re: C++ detail question

>> its guaranteed to be C compatible, which leads to the data elements
>> coming first.
>
>OK, so second question.  If I cast a "struct Foo *" to a "class CFoo *",
>what happens?  Can I use non-virtual methods on it?  Can I use virtual
>methods on it?
>
>Obviously, I could not access any data members that are part of CFoo but
>not Foo, right?

not sure if i understand the question completely. which one is
declared in what language?

you definitely can't use virtual methods, and you probably shouldn't
attempt to use ordinary methods. about the only things you can use
from C for a C++ object are static members. "static" here has nothing
really to do with scope in the C sense. it just means that they are
not called with an implicit "this" pointer, and have linkage similar
(but not the same as) to a normal C function. 

notice, however, that some C and C++ compilers will not allow calling
functions declared within a C++ linkage scope from a C linkage scope.
libsigc++ was just bitten by this: the solaris C++ compiler turns out
to be the only one so far to enforce it, but on investigation, it is
correct according to the language specifications.

--p

----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: http://www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: