Posted on 2011-02-28 16:28
点点滴滴 阅读(202)
评论(0) 编辑 收藏 引用 所属分类:
02 编程语言
class test1
{
public:
virtual void animation()
{
cout << "test1 animation" << endl;
}
virtual void animation1() = 0;
};
class test2 : public test1
{
public:
virtual void animation1()
{
cout << "test2 animation1" << endl;
}
void animation()
{
cout << "test2 animation" << endl;
}
};
class test3 :public test2
{
void animation1()
{
cout << "test3 animation1" << endl;
}
void animation()
{
cout << "test3 animation" << endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
// allocatePractice();
test1* test = new test3();
test->animation();
test->animation1();
// //定义
// std::pair<int, string> ming(1,"ming1");
// std::map<int ,string> authors;
// //插入
// authors.insert(make_pair(3,"ming3"));
// authors.insert(map<int, string>::value_type(2,"ming2"));
// authors.insert(ming);
//
// cout << authors[4] << endl;
return 0;
}
virtual 为重载关键字,父类方法加上这个关键字,可以实现重载
输出:
test3 animation
test3 animation1