|
发表于 2013-8-15 17:42:40
|
显示全部楼层
- #include <iostream>
- #include <string>
-
- class Lovers
- {
- public:
- //lovers(std::string theName);
- Lovers(std::string theName);
- void kiss(Lovers *Lover);
- void ask(Lovers *Lover, std::string something);
-
- protected:
- std::string name;
-
- friend class Others;
- };
-
- class Boyfriend : public Lovers
- {
- public:
- Boyfriend(std::string theName);
- };
- class Girlfriend : public Lovers
- {
- public:
- Girlfriend(std::string theName);
- };
-
- class Others
- {
- public:
- Others(std::string theName);
- void kiss(Lovers *Lover);
-
- protected:
- std::string name;
- };
-
- //Lovers::lovers(std::string theName)
- Lovers::Lovers(std::string theName)
- {
- name = theName;
- }
-
- void Lovers::kiss(Lovers *Lover)
- {
- std::cout << name << "亲亲我们家的" << Lover->name << std::endl;
- }
-
- void Lovers::ask(Lovers *Lover, std::string something)
- {
- std::cout << "宝贝儿" << Lover->name <<"帮我" << something << std::endl;
- }
- Boyfriend::Boyfriend(std::string theName):Lovers(theName)// 这里开始出错的。。。。。。
- {
- }
-
- Girlfriend::Girlfriend(std::string theName) : Lovers(theName)
- {
- }
- int main()
- {
- return 0;
- }
复制代码 |
|