我在工作,我们完全锁定了计算机。我这里没有SSH终端。我有很多停机时间,我的意思是很多的停机时间,因为我很快完成了工作。我在网上上学的时候,如果我在学习的时候可以以某种方式编译一些基本的C ++代码,那将会很棒。
有什么想法吗?
我记得有一个代码粘贴网站,你可以选择检查非常基本的C ++代码的输出。那个网站是什么?
必须有一些方法可以编译非常基本的C ++代码,如下所示:
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;
}
答案 0 :(得分:2)
有许多在线C ++编译器article有一个很好的列表。虽然看起来Cameau
已经消失,但LiveWorkSpace
已经处于只读模式一段时间了。 godbolt
是列表中的奇数,因为它确实显示了汇编输出而不是运行代码。