评论会员:游客 时间:2012/02/05
谷歌是你的朋友是好,经常看望他。他可以回答问题快,超过了他们在这里发布了...imgsrc=http://www.orcode.com/img/ico/smiley_smile.gif顶部的结果:imgsrc=http://www.orcode.com/img/ico/smiley_wink.gif]
西蒙邦Terkildsen:看看这些
{A2}
{A3的}
{A4纸}]
评论会员:米卡Wendelius 时间:2012/02/05
数:
- {A5的}
- {A6的}]
评论会员:CPallini 时间:2012/02/05
Polimorphism是面向对象编程的基本支柱之一。你不能希望了解它从一个"快速的答案"。买(好)OOP的书和学习
评论会员:游客 时间:2012/02/05
。阿伦的Parthasarathy
多态性,在面向对象编程中的能力,以创建一个变量,函数,或一个对象有一个以上的形式{BR }多态性是不相同的方法重载或重写方法。[1]多态性仅应用到一个接口或一个更通用的基类的具体实现有关。方法重载是指同一类内的名称相同,但不同的签名方法。方法重载是一个子类替换一个或多个其母公司的方法执行。既不方法重载,也没有方法重载是多态性的实现。[2]
请看看下面的程序。
只是编译和调试。你会看到精彩的性质或多态性。
如果你不明白恢复会解释..
来源 - 维基百科
#include <iostream>
#include <string>
using namespace std;
class Animal {
public:
Animal(const string& name) : name(name) {}
virtual string talk() = 0;
const string name;
};
class Cat : public Animal {
public:
Cat(const string& name) : Animal(name) {}
virtual string talk() { return "Meow!"; }
};
class Dog : public Animal {
public:
Dog(const string& name) : Animal(name) {}
virtual string talk() { return "Woof! Woof!"; }
};
// prints the following:
//
// Missy: Meow!
// Mr. Mistoffelees: Meow!
// Lassie: Woof! Woof!!
//
int main() {
Animal* animals[] = {
new Cat("Missy"),
new Cat("Mr. Mistoffelees"),
new Dog("Lassie")
};
for (int i = 0; i < 3; ++i) {
cout << animals[i]->name << ": " << animals[i]->talk() << endl;
delete animals[i];
}
}
</string></iostream>
评论会员:游客 时间:2012/02/05
尤金Podsypalnikov:A7的{|}]可设计也{S0的}{C}