标签:string ios dbf hide int play void amp define
#include <iostream> #include "MachinePets.h" #include "PetCats.h" #include "PetDogs.h" #include <string> using namespace std; void play(MachinePets *p){ cout<<p->getNickname()<<"says"<<p->talk()<<endl; } int main(){ PetCats cat("miku"); PetDogs dog("da huang"); play(&cat); play(&dog); return 0; }
#ifndef PETDOGS_H #define PETDOGS_H #include "MachinePets.h" #include <string> using namespace std; class PetDogs:public MachinePets{ public: PetDogs(const string s); string talk(); }; #endif
#include <iostream> #include "PetDogs.h" #include <string> using namespace std; PetDogs::PetDogs(const string s):MachinePets(s){ } string PetDogs::talk(){ cout<<"says wang wang~"<<endl; }
#include <iostream> #include "PetDogs.h" #include <string> using namespace std; PetDogs::PetDogs(const string s):MachinePets(s){ } string PetDogs::talk(){ cout<<"says wang wang~"<<endl; }
#include "MachinePets.h" #include "PetCats.h" #include <string> #include <iostream> using namespace std; PetCats::PetCats(const string s):MachinePets(s){ } string PetCats::talk(){ cout<<"says miao wu~"<<endl; }
#ifndef MACHINEPETS_H #define MACHINEPETS_H #include <string> #include <iostream> using namespace std; class MachinePets{ private: string nickname; public: MachinePets(const string s); string getNickname(); virtual string talk()=0; }; #endif
#include "MachinePets.h" #include <iostream> #include <string> using namespace std; MachinePets::MachinePets(const string s):nickname(s){ } string MachinePets:: getNickname(){ return nickname; }
标签:string ios dbf hide int play void amp define
原文地址:https://www.cnblogs.com/sunny0202/p/10960561.html