online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
// Example program #include <iostream> #include <string> #include <ctime> #include <iostream> #include <chrono> #include <string> #include <time.h> #include <cstdlib> #include <thread> class Person { private: std::string imie; std::string nazwisko; public: virtual void show(); Person(const char * i ="default",const char * n = "default"): imie(i),nazwisko(n){}; virtual ~Person() = 0; }; class Gunsligner : public virtual Person { private: int cuts; public: void getC(){std::cout<<cuts;} double draw(); Gunsligner(const char * i ="default",const char * n = "default", int c = 0): Person(i,n),cuts(c){}; virtual void show(); }; class Poker : public virtual Person { public: Poker(const char * i ="default",const char * n = "default"):Person(i,n){}; int draw();//1:52; virtual void show(); }; class Bad : public Gunsligner, public Poker { public: Bad(const char * i = "default", const char * n ="default",int c = 0 ) : Person(i,n),Gunsligner(i,n,c){}; double Gdraw(){return Gunsligner::draw();} int Cdraw(){return Poker::draw();} virtual void show(); }; using namespace std; Person::~Person() {}; void Person::show() { cout<<imie<<"\n"<<nazwisko<<"\n"; } void Gunsligner::show() { Person::show(); cout << "Czas wyciagania pistoletu: " <<Gunsligner::draw()<<endl; cout <<"Liczba naciec: " <<cuts<<"\n"; } void Poker::show() { Person::show(); cout << "Karta ma numer: " <<Poker::draw(); cout<<endl; } void Bad::show() { Person::show(); cout << "Czas wyciagania pistoletu: " <<Gdraw()<<endl; cout<< "Liczba naciec: "; getC(); cout << "Karta ma numer: " <<Cdraw()<<endl; cout<<endl; } int Poker::draw() { srand(time(NULL)); return rand()%52+1; } double Gunsligner::draw() { srand(time(NULL)); int c; int a = rand()% 10+1; int b = rand()% 100+1; if(a%2 == 0 ) c = rand()% 78+1; else c= rand()%56+1; return (double)(a+b)/c; } int main() { Gunsligner f; Gunsligner s; std::cout<<f.draw(); std::this_thread::sleep_for (std::chrono::seconds(1)); std::cout<<'\n'<<s.draw(); }

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