Re: Interfaces in C++
XPCom is little more than a pillage of Microsoft COM. Both, at their =
base level consist of declaring a C++ class containing pure virutal =
methods and compiling with a compatible compiler. Ensuring that even c++ =
interfaces intended to be used only by homogeneous (c++) code are =
nonetheless compatible at a binary level means that code can easilly =
move from a homogeneous to a heterogeneous environment.
Which is just good software engineering practice.
Not everyone uses c++. .so and .dll files are (depending on your =
platform) common ways to glue binary files (from teams with different =
toolsets) together .
The virtual keyword prevents that interface and any derived interfaces =
ever being exported in a binary compatible way (on compilers that =
otherwise produce interfaces in a way that DOES conform to COM/XPComs =
binary interface requirements). If you are developing reusable code you =
can never know how its going to need to be used in the future. don't =
shoot yourself in the foot and rely on this broken mechanism. It might =
be good "c++". but its bad computer science. It violates the earliest =
principals computer science students are taught about avoiding coupling.
"Maik" <Beckmann.Maik@googlemail.com> wrote in message =
news:88a7b48c-d154-4a8d-8ac8-49e05f15251f@w13g2000prm.googlegroups.com...=
On 7 Okt., 10:46, "Chris Becke" <chris.be...@gmail.com> wrote:
You cant do that. On many platforms interfaces are a binary interop =
used and supported by languages other than c++.
In order to interop however, the vtable for the interface MUST be =
contiguous.
Clearly if you are working in a ahomogonous c++ only environment you =
can use virtual like that. But, despite the c++ standards body being =
unwilling to acknoledge it, c++ vtables *are* used for binary interop =
rendering this keyword worse than useless.
The C++ interfaces pattern uses the C++ compiler and runtime library
to make a C++ developers life easier.
In case of closed source software an extra C-API might be sufficient
to support a big set of C/C++ compilers in different versions.
Heterogeneous software projects need other tools (SWIG, CORBA,
XPCom,... ).
Best,
-- Maik
PS: Top-Posting is evil :)