Hei,
Tarvitsisin apua tehtävän viimeistelyyn.
#include
#include
using namespace std;
// Oma koodi alkaa
class Dog {
public:
int age;
string name, race, voice;
Dog(int age2,string name2,string race2,string voice2);
void PrintInformation();
void Bark();
};
Dog::Dog(int age2,string name2,string race2,string voice2) {
age = age2;
name = name2;
race = race2;
voice = voice2;
}
void Dog::PrintInformation() {
cout << "Name: " << name;
cout << "\nAge: " << age;
cout << "\nRace: " << race << endl;
}
void Dog::Bark(){
cout << voice << endl;
}
// Oma koodi loppuu
int main()
{
Dog buffy(2, "Buffy", "Bulldog", "Hau!!!");
buffy.PrintInformation();
cout << "Dog says: " << buffy.Bark();
}
Ohjelma valittaa osiosta
buffy.PrintInformation();
cout << "Dog says: " << buffy.Bark();
}
Tarvitsisin apua tehtävän viimeistelyyn.
#include
#include
using namespace std;
// Oma koodi alkaa
class Dog {
public:
int age;
string name, race, voice;
Dog(int age2,string name2,string race2,string voice2);
void PrintInformation();
void Bark();
};
Dog::Dog(int age2,string name2,string race2,string voice2) {
age = age2;
name = name2;
race = race2;
voice = voice2;
}
void Dog::PrintInformation() {
cout << "Name: " << name;
cout << "\nAge: " << age;
cout << "\nRace: " << race << endl;
}
void Dog::Bark(){
cout << voice << endl;
}
// Oma koodi loppuu
int main()
{
Dog buffy(2, "Buffy", "Bulldog", "Hau!!!");
buffy.PrintInformation();
cout << "Dog says: " << buffy.Bark();
}
Ohjelma valittaa osiosta
buffy.PrintInformation();
cout << "Dog says: " << buffy.Bark();
}
Vastaukset 1
Vanhimmat
cout << "Dog says: ";
buffy.Bark();
cout << endl;