#include #include #include #include class Var { public: Var(std::string str) // TODO initiate implementation as a String from str { } Var(int number) // TODO initiate implementation as a String from number { } // TODO add memory managment and special members void add(int number) { // TODO call add(number) on implementation } void concat(std::string str) { // TODO call cancat(str) on implementation } void print(std::ostream& os) { // TODO call print(os) on implementation } private: // TODO data member named "implementation" to represent either a Number or a String }; /* Körexempel: 5 7 757 17 Cannot concat number */ int main() { Var n { 5 }; Var s { "7" }; n.print(std::cout); std::cout << std::endl; s.print(std::cout); std::cout << std::endl; s.add(5); s.concat("7"); s.print(std::cout); std::cout << std::endl; n.add(12); n.print(std::cout); std::cout << std::endl; try { n.concat("hello"); } catch // TODO catch something suitable to exception variabel "e" { std::cout << e.what() << std::endl; } }