C++ 如何显示一个类的所有信息?

C++ 如何显示一个类的所有信息?,c++,C++,我刚开始编写代码,很抱歉,如果代码太复杂或凌乱,任何提示都是宝贵的 #include <iostream> using namespace std; class Nacion { public: string nombre; string tematica; string entorno; Nacion (string aNombre , string aTematica , string aEntorno){ nom

我刚开始编写代码,很抱歉,如果代码太复杂或凌乱,任何提示都是宝贵的

#include <iostream>

using namespace std;


class Nacion {
public:
    string nombre;
    string tematica;
    string entorno;
    Nacion (string aNombre , string aTematica , string aEntorno){
              nombre = aNombre;
              tematica = aTematica;
              entorno = aEntorno;
    }


};

int main(){
int eligNac;
string Categoria;
string Naciones;

Nacion nacion1 ("nombre" , "tematica" , "entorno");
Nacion nacion2 ("nombre" , "tematica" , "entorno");
Nacion nacion3 ("nombre" , "tematica" , "entorno");

cout << "Elije una categoria:\n";
cout << "Naciones\n";
cout << "Campeones" << endl;
cin >> Categoria;
if (Categoria == "Naciones")
    {

    cout << "Elije una nación:\n";
    cout << "1.-Demacia\n";
    cout << "2.-Freldjord\n";
    cout << "3.-Piltover\n" << endl;

    cin >> eligNac  >> endl;
    if(eligNac = 1){
      cout << nacion1 << endl;
    }



}
#包括
使用名称空间std;
Nacion类{
公众:
字符串名称;
弦提肌;
弦内耳环;
Nacion(串aNombre、串aTematica、串aEntorno){
nombre=无模体;
tematica=阿泰马蒂卡;
恩托诺=恩托诺;
}
};
int main(){
内部语言;
弦范畴;
串珠;
Nacion nacion1(“名称”、“tematica”、“entorno”);
Nacion nacion2(“名称”、“tematica”、“entorno”);
Nacion nacion3(“名称”、“tematica”、“entorno”);

CUT

你可能想研究C++运算符重载:具体来说,操作程序,你对这条“一行代码”有什么问题会更清楚吗?请解释一下你的问题有点好(如果ELICANC=1)应该是=:CIN>ELICANC>EnDL;如果(ELICANC=1){CUT

std::ostream & operator<<(std::ostream & os, const Nacion & n) {
    os << n.nombre << " / " << n.tematica << " / " << n.entorno << std::endl;
    return os;
}