online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> class 能力 { public: virtual ~能力() = default; virtual std::string 取能() = 0; }; class 直立能力 : public 能力 { public: std::string 取能() override { return "我的一小步,是人类进化的一大步"; } }; class 智慧能力 : public 能力 { public: std::string 取能() override { return "香蕉诚可贵,自由价更高。若为进化故,二者皆可抛"; } }; class 下半身超能力 : public 能力 { public: std::string 取能() override { return "嘿嘿嘿嘿嘿……"; } }; //------------------------------------------------------------- class 猩猩 { public: virtual ~猩猩() = default; virtual void 行走() { std::cout << "爬、爬、爬" << std::endl; } virtual void 思考猩生() { std::cout << "猩生就是吃香蕉" << std::endl; } }; class 直立猩 : public 猩猩 { public: void 行走() override { std::cout << 直立.取能() << std::endl; } protected: 直立能力 直立; }; class 智慧猩 : public 猩猩 { public: void 思考猩生() override { std::cout << 智慧.取能() << std::endl; } protected: 智慧能力 智慧; }; class 直立智慧猩 : public 猩猩 { public: 直立智慧猩() : 下半身(nullptr) {} ~直立智慧猩() override { delete 下半身; } void 设定贤者(bool 是) { if(是) { delete 下半身; 下半身 = nullptr; } else if (!下半身) { 下半身 = new 下半身超能力; } } void 行走() override { std::cout << 进化代价(&直立, "走") << std::endl; } void 思考猩生() override { std::cout << 进化代价(&智慧, "思考猩生") << std::endl; } protected: std::string 进化代价(能力* 原始能, std::string const& action) { if (!下半身) { return 原始能->取能(); } // 下半身思考 : return "我不想" + action + ",我只想" + 下半身->取能() + "\n\t你让我" + 下半身->取能() + ",我才想:" + 原始能->取能(); } protected: 直立能力 直立; 智慧能力 智慧; 下半身超能力* 下半身; }; void 秀(猩猩 *xx, char const* type) { std::cout << "我是一只" << type << "猩"; std::cout << "\n我的行走就是:"; xx->行走(); std::cout << "偶尔我也会思考猩生:"; xx->思考猩生(); std::cout << std::endl; } int main() { 猩猩 xx; 秀(&xx, "普通"); 直立猩 zlx; 秀(&zlx, "直立"); 智慧猩 zhx; 秀(&zhx, "智慧"); 直立智慧猩 zlzhx; 秀(&zlzhx, "直立智慧"); zlzhx.设定贤者(false); 秀(&zlzhx, "下半身超能直立智慧"); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue