PODS for C++ programmers

The objective of this section is to leverage your existing knowledge of C++ to help you get familiar with the PODS C environment. If you are not a C++ programmer, this section may teach you a little about C++, but it probably will not help much in familiarizing you with the PODS C environment. You may safely skip this topic and go on to Implementing a PODS interface in C.

At first glance, a C++ programmer might not recognize the features of an OO development system as PODS provides them. Because PODS is compatible with pure ANSI C, none of the syntactic constructions familiar to a C++ programmer are available, but the actual functionality behind them is. You must explicitly tell the compiler what to do at a low level rather than using advanced syntax to hide the advanced features. PODS provides some convenient macros to help when dealing with standard classes. (If you've never investigated how a C++ compiler provides inheritance, virtual method calls, and polymorphism, you may find exploration of the PODS macros illuminating, but this document will focus on syntactic issues.)

The most obvious differences between PODS C source code and C++ source code are the syntax of a virtual method call and the lack of implied upcasting. The pattern is fairly simple but will require some changes of habit. Where in C++ you would write

// might be explicit with
// static_cast<ParentClass*>(ChildClassPtr)
ParentClass *foo = ChildClassPtr;
foo->Bar(1, 2);

In PODS and C you would write

// cast is required
ParentClass *foo = (ParentClass*) ChildClassPtr;
PODSbar(foo, 1, 2);

Virtual method calls and member data: vtables
Construction and destruction
Advanced C++ concepts