编译没有终端或SSH访问的c++

Compiling C++ without terminal or SSH access?

本文关键字:访问 c++ SSH 终端 编译      更新时间:2023-10-16

我在工作,我们已经完全锁定了电脑。我这里没有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;
}

网上有很多c++编译器,本文有一个很好的列表。虽然看起来Cameau已经消失,LiveWorkSpace已经处于只读模式一段时间了。godbolt是列表中奇怪的一个,因为它确实显示了您的汇编输出,而不是运行代码。