Posts

Showing posts from September, 2006

standard C++ OOP features (codes)

#include "stdafx.h" #include cstdlib> #include iostream> #define OUT using namespace std; class A { private : int iMyNum; void APrivateFunc() { } public : A() { iMyNum = 100; } friend ostream& operator //made as friend function for performance reason void MyFunc() { printf( "myfunct" ); } }; ostream&operator class B : private A { public : B():A() { } int iMyB; using A::MyFunc; //only for the member variables which already originaly //accessible but during inheris access specifier specify as private instead of public //using A::APrivateFunc; //this is not valid APrivateFunc before that is a private function. }; class A1 { protected : int iMyA1; public : int GetMyA1() { return iMyA1;} }; class B1: public A1 { public : int iMyB1; B1():A1() { } B1 & operator = (A1 &a1) { A1::iMyA1 = a1.GetMyA1(); return * this ; } }; // o (based) // /\ // o o (derived) // \ / // o (grandchild) //hybrid inheritance base class class Base { in...