ITSELF.CPP
资源名称:C++100.rar [点击查看]
上传用户:wszmarenbt
上传日期:2013-04-26
资源大小:2552k
文件大小:1k
源码类别:
Windows编程
开发平台:
Visual C++
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- class RELATIONSHIP
- {
- private :
- RELATIONSHIP *BABY;
- char * NAME;
- public :
- RELATIONSHIP(char *Name);
- void CreateBaby(char * BABY_NAME);
- void Display_People();
- void Display_Baby();
- void Display_Baby_Baby();
- };
- RELATIONSHIP::RELATIONSHIP(char *Name)
- {
- NAME=new char[strlen(Name)+1];
- strcpy(NAME,Name);
- BABY=0;
- }
- void RELATIONSHIP::CreateBaby(char *BabyName)
- {
- BABY=new RELATIONSHIP(BabyName);
- }
- void RELATIONSHIP::Display_People()
- {
- printf("The first people:%s",this->NAME);
- }
- void RELATIONSHIP::Display_Baby()
- {
- printf("Her baby :%s",this->BABY->NAME);
- }
- void RELATIONSHIP::Display_Baby_Baby()
- {
- printf("Her baby's baby:%s",this->BABY->BABY->NAME);
- }
- int main(void)
- {
- RELATIONSHIP People("L1");
- People.CreateBaby("L2");
- clrscr();
- People.Display_People();
- People.Display_Baby();
- People.Display_Baby_Baby();
- getch();
- return 0;
- }