【发布时间】:2021-12-20 05:27:50
【问题描述】:
void Dog::readDog()
{
cout << "Name: ";
cin >> this->name;
cout << "height: ";
cin >> this->height;
cout << "weight: ";
cin >> this->weight;
cout << "Color: ";
cin >> this->color;
}
void Dog::printDog()
{
cout << "Name: " << this->name << endl;
cout << "Height: " << this->height << endl;
cout << "Weight: " << this->weight << endl;
cout << "Color: " << this->color << endl;
}
int main() {
Dog dogs;
int n;
cout << "Number of dogs to introduce: ";
cin >> n;
dogs.readDog();
dogs.printDog();
}
这是我的代码的一部分,我有一个小问题,因为我忘记了如何设置一些我想在程序中引入的狗,例如我想要 3 条狗:Max、Rex、Terry。我的程序只读取和打印一只狗
【问题讨论】: