Wednesday, June 23, 2004

Relearning C++ and Random Thoughts 2

- geared toward performance.
function calls involve execution-time overhead. C++ provies inline functions to help reduce function-call overhead--especially for small functions. The qualifier inline "advises" the compiler to generate a copy of the function's code in place (when appropriate) to avoid a function call.

--side effect it can increase the program size.

class ha_example: public handler { }
An example of Polymorphisam-the principle of inheritance. Classes are related by inheritance but respond differently to the same message better known as member function calls.

Relearning C++ and Random Thoughts

As I read some code at work today, code written in C++ I find myself at a bit of a loss. So, what I'm learning I will write down and hopefully I will start coding soon.

using namespace MAIN
using software components from the MAIN Libaries
- make libiries unique from one another
- if 2 libs have the same methods qualify the namespace
- each namespace defines a scope where a global identifier and global variables are placed.

fully qualify namespace calls
namespace MAIN::member


extern "C" function prototype
extern "C" { BLOCK }
- tell the compiler don't do the above in C++ do it at linker time

virtual - Polymorphism / Dynamic allocaed objects - keywords
in use with destructors in an inherited situation calling delete on an object will use the BASE CLASS destructor. This is not good. Use virtual ~class to get around calling the base class destructor and its own.

declaired const by both in its prototype and its definition by inserting the keyword after the functions parameter list.
OBJECT function const { BLOCK }

Object Pointers
Object *objectPTR, object, objectref;

objectPTR = &object
(*objectPTR).member == objectPTR->member. This syntax is needed because the dot operator has higher precense then the above 2 versions of the syntax.