Reputation: 2833
I'm at work and we have completely locked down computers. I have no SSH terminal on here. I have a lot of downtime and I mean a lot of downtime since I get my work done quickly. I'm doing school online while working and it would be great if I could somehow compile some basic C++ code when I'm studying.
Any ideas?
I remember there was a code pasting site where you had the option of checking the output of very basic C++ code. What was that site?
There has to be some way I can compile very basic C++ code, stuff like this:
class Teapot {
int cups;
char* desc;
public:
Teapot();
Teapot(int c, const char* d);
Teapot(const Teapot&);
~Teapot();
Teapot& operator=(const Teapot&);
void operator=(int n);
void operator=(const char*);
void display() const;
};
// Teapot.cpp
#include <iostream>
#include <cstring>
using namespace std;
#include "Teapot.h"
Teapot::Teapot() {
cups = 0;
desc = NULL;
}
Teapot::Teapot(int c, const char* d) {
if (c > 0 && d != NULL) {
cups = c;
desc = new char[strlen(d) + 1];
strcpy(desc, d);
}
else {
desc = NULL;
*this = Teapot();
}
}
Teapot::Teapot(const Teapot& t) {
desc = NULL;
*this = t;
}
Teapot& Teapot::operator=(const Teapot& t) {
if (this != &t) {
delete [] desc;
cups = t.cups;
if (t.desc != NULL) {
desc = new char[strlen(t.desc) + 1];
strcpy(desc, t.desc);
}
else {
desc = NULL;
}
}
return *this;
}
Teapot::~Teapot() {
delete [] desc;
}
void Teapot::operator=(int n) {
if (desc != NULL && n > 0) cups = n;
}
void Teapot::operator=(const char* d) {
if (d != NULL) {
delete [] desc;
desc = new char[strlen(d) + 1];
strcpy(desc, d);
cups = 0;
}
}
void Teapot::display() const {
if (desc != NULL)
cout << cups << ' ' << desc << endl;
else
cout << "Empty" << endl;
}
Upvotes: 1
Views: 233
Reputation: 158469
There are many online C++ compilers this article has a good list. Although it looks like Cameau
is gone and LiveWorkSpace
has been in read only mode for a while now. godbolt
is the odd one out on the list since it really shows your the assembly output rather than runs the code.
Upvotes: 2