Download source code: HelloWorld.zip
1. Create two folders Base and World in a root folder for you HelloWorld example.
2. Create a file Hello.h in folder
Base with the following content:
//File Base/Hello.h #include <stdio.h> class Hello { public: int run() { printf("Hello"); return 0; } }; int main() { //create instance of "test" Hello myHello; //run Hello::run as entry-point of the app return myHello.run(); }This is the base applicatin which prints "Hello" in method Hello::run. The method main creates an instance of class Hello and calls run.
//File World/Hello.h refines class Hello { public: int run() { //invoke refined method int res = super::run(); if (res!=0) return res; printf(" World!"); return 0; } };
Base World
> fc++ -gpp HelloWorld > make .output.HelloWorld/Hello > .output.HelloWorld/Hello5b. On Windows using the MS compiler run the following commands:
> fc++ HelloWorld > cl .output.HelloWorld/Hello.cpp > Hello