标签:blog io ar os sp 2014 log as c++
#include <iostream> #include <string> using namespace std; class Pet { protected: string name; public: void setname(string aname) { this->name = aname; } virtual string bark() { return name + ", Hello"; } }; class Dog : public Pet { public: virtual string bark() { string tmp = Pet::bark(); return tmp + ", dog"; } }; int main() { Dog d; d.setname("doga"); cout << d.bark() << endl; return 0; }
标签:blog io ar os sp 2014 log as c++
原文地址:http://blog.csdn.net/miscclp/article/details/40820821