int main(){ Dog d; int i = 9; d.setAge(i); cout << i << endl; }
int main() { Dog x; x.setName("Lerothodi"); x.setAge(5); x.setWeight(60); x.setBreed("German Shepherd"); cout << "Name : " << x.getName() << endl; cout << "Age : " << x.getAge() << " years." << endl;; cout << "Weight : " << x.getWeight() << " lb." << endl; cout << "Breed : " << x.getBreed() << endl; cout << "Lifespan: " << x.getLifespan() << endl; cout << endl; Pet y; y.setName("Leeuw"); y.setAge(7); y.setWeight(55); cout << "Name : " << y.getName() << endl; cout << "Age : " << y.getAge() << " years." << endl;; cout << "Weight : " << y.getWeight() << " lb." << endl; cout << "Lifespan: " << y.getLifespan() << endl; return 0; }
int main() { Dog fido; fido.setAge(3); fido.setWeight(15); fido.setColor("brown"); cout << "Fido is a " << fido.getColor() << " dog" << endl; cout << "Fido is " << fido.getAge() << " years old" << endl; cout << "Fido weight" << fido.getWeight() << " pounds" << endl; fido.bark(); return 0; }
int main() { Dog d; int i=9; d.setAge(i); // Compile error :- ambiguity amongst "void setAge(const int a)" and "void setAge(int &a)" cout<<i<<endl; const string& n = d.getName(); cout<<n<<endl; return 0; }