当前位置: 首页>>代码示例>>C++>>正文


C++ Dog::setWeight方法代码示例

本文整理汇总了C++中Dog::setWeight方法的典型用法代码示例。如果您正苦于以下问题:C++ Dog::setWeight方法的具体用法?C++ Dog::setWeight怎么用?C++ Dog::setWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dog的用法示例。


在下文中一共展示了Dog::setWeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

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;
}
开发者ID:nurur,项目名称:Cpp-Programming,代码行数:28,代码来源:petProg.cpp

示例2: main

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;
}
开发者ID:s501870,项目名称:CPP_InEasyStep,代码行数:12,代码来源:object.cpp

示例3: main

int main() {
    std::cout << "DOG:" << std::endl;
    Dog myDog;
    myDog.setName("Barkley");
    myDog.setWeight(10);
    myDog.print();
    std::cout << "OWNEDDOG:" << std::endl;
    OwnedDog ownedDog;
    ownedDog.setName("OwnedBarkley");
    ownedDog.setOwner("Ale");
    ownedDog.setWeight(20);
    ownedDog.print(); 
    return 0;
} 
开发者ID:irr,项目名称:c-labs,代码行数:14,代码来源:oop.cpp

示例4: dogOut

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;
}
开发者ID:szhongren,项目名称:H212,代码行数:6,代码来源:lab8.cpp


注:本文中的Dog::setWeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。