online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include<map> #include<string> #include<vector> class ColorBlind { public: static bool toggleColorBlind;; //^^^^^^ ^^^^^^------------------------------------->note only the static used here }; //define it outside class bool ColorBlind::toggleColorBlind = false; class Menu { public: //method that toggles void invertColorBlind() const { ColorBlind::toggleColorBlind = !ColorBlind::toggleColorBlind; std::cout<<"changed to: "<<ColorBlind::toggleColorBlind<<std::endl; } }; class Game { public: void invertColorBlind() const { ColorBlind::toggleColorBlind = !ColorBlind::toggleColorBlind; std::cout<<"changed to: "<<ColorBlind::toggleColorBlind<<std::endl; } }; int main() { std::cout<<"Initially toggleColorBlind is: "<<ColorBlind::toggleColorBlind<<std::endl; //prints 0 Menu m; //lets change toggleColorBlind using an instance of Menu m.invertColorBlind(); //prints 1 //toggle again m.invertColorBlind(); //prints 0 Game g; //lets change toggleColorBlind using an instance of Game g.invertColorBlind(); //print 1 }

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