本文整理汇总了C++中Dog::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Dog::getName方法的具体用法?C++ Dog::getName怎么用?C++ Dog::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dog
的用法示例。
在下文中一共展示了Dog::getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
Shelter sh;
Cat c1("Cat1");
Cat c2("Cat2");
Cat c3("Cat3");
Dog d1("Dog1");
Dog d2("Dog2");
Dog d3("Dog3");
sh.enqueue(c1);
sh.enqueue(d1);
sh.enqueue(d2);
sh.enqueue(c2);
sh.enqueue(c3);
sh.enqueue(d3);
Animal ani = sh.dequeueAny();
cout << "DeuqeAny: " << ani.getName() << endl;
Cat cc = sh.dequeueCat();
cout << "DeuqeCat: " << cc.getName() << endl;
Dog dd = sh.dequeueDog();
cout << "DeuqeDog: " << dd.getName() << endl;
}
示例2: main
int main()
{
Shelter aq;
Cat c1("Cat1");
Cat c2("Cat2");
Cat c3("Cat3");
Dog d1("Dog1");
Dog d2("Dog2");
Dog d3("Dog3");
aq.enqueue(d1);
aq.enqueue(c1);
aq.enqueue(c2);
aq.enqueue(c3);
aq.enqueue(d2);
aq.enqueue(d3);
Animal a = aq.dequeueAny();
cout << "Get your pet: " << a.getName() << endl;
Cat c = aq.dequeueCat();
cout << "Get your cat: " << c.getName() << endl;
Dog d = aq.dequeueDog();
cout << "Get your dog: " << d.getName() << endl;
return 0;
}
示例3: 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;
}
示例4:
Dog::Dog(Dog &oldDog)
{
name = new char[17];
strncpy( name, oldDog.getName(), 16 );
name[16] = '\0';
height = oldDog.getHeight();
weight = oldDog.getWeight();
}
示例5: main
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;
}
示例6:
void QT1::listItemChanged()
{
int idx = this->getRepoListSelectedIndex();
if (idx == -1) return;
std::vector<Dog> dogs = this->currentDogsInRepoList;
if (idx > dogs.size())return;
Dog s = dogs[idx];
this->nameEdit->setText(QString::fromStdString(s.getName()));
this->breedEdit->setText(QString::fromStdString(s.getBreed()));
QString w;
w.setNum(s.getAge());
this->ageEdit->setText(w);
this->linkEdit->setText(QString::fromStdString(s.getPhotograph()));
}
示例7: 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;
}