Difference between revisions of "CPP/StaticInheritance"
From ProgrammingExamples
< CPP
Daviddoria (Talk | contribs) (Created page with '==StaticInheritance.cpp== <source lang="cpp"> #include <iostream> class Parent { public: static double GetValue(); }; double Parent::GetValue() { return 2.0; } class Child…') |
(No difference)
|
Latest revision as of 15:49, 19 December 2011
StaticInheritance.cpp
#include <iostream> class Parent { public: static double GetValue(); }; double Parent::GetValue() { return 2.0; } class ChildWithReimplement : public Parent { public: static double GetValue(); }; double ChildWithReimplement::GetValue() { double parentValue = Parent::GetValue(); return parentValue + 3.0; } class Child : public Parent { }; int main(int argc, char* argv[]) { std::cout << "parent: " << Parent::GetValue() << std::endl; std::cout << "child: " << Child::GetValue() << std::endl; std::cout << "ChildWithReimplement: " << ChildWithReimplement::GetValue() << std::endl; return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) Project(StaticInheritance) ADD_EXECUTABLE(StaticInheritance StaticInheritance.cpp)