Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
Arquivo: Dog.cpp Projeto: hef/siggame
Dog::Dog(Dog &oldDog)
{
	name = new char[17];
	strncpy( name, oldDog.getName(), 16 );
	name[16] = '\0';

	height = oldDog.getHeight();
	weight = oldDog.getWeight();
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
void dogOut(const Dog& d)
{
	cout << "This is a " << d.getName() << " and it has a weight of " << d.getWeight() << "." << endl
		<< "The value returned when setweight is run is " << d.setWeight() << " and its fur color is " << d.getFurCol() << endl
		<< "They are all threatened by " << d.getThreats() << endl;
}