ITSELF.CPP
上传用户:wszmarenbt
上传日期:2013-04-26
资源大小:2552k
文件大小:1k
源码类别:

Windows编程

开发平台:

Visual C++

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4. class RELATIONSHIP
  5. {
  6. private :
  7. RELATIONSHIP *BABY;
  8. char * NAME;
  9. public :
  10. RELATIONSHIP(char *Name);
  11. void CreateBaby(char * BABY_NAME);
  12. void Display_People();
  13. void Display_Baby();
  14. void Display_Baby_Baby();
  15. };
  16. RELATIONSHIP::RELATIONSHIP(char *Name)
  17. {
  18. NAME=new char[strlen(Name)+1];
  19. strcpy(NAME,Name);
  20. BABY=0;
  21. }
  22. void RELATIONSHIP::CreateBaby(char *BabyName)
  23. {
  24. BABY=new RELATIONSHIP(BabyName);
  25. }
  26. void RELATIONSHIP::Display_People()
  27. {
  28. printf("The first people:%s",this->NAME);
  29. }
  30. void RELATIONSHIP::Display_Baby()
  31. {
  32. printf("Her baby :%s",this->BABY->NAME);
  33. }
  34. void RELATIONSHIP::Display_Baby_Baby()
  35. {
  36. printf("Her baby's baby:%s",this->BABY->BABY->NAME);
  37. }
  38. int main(void)
  39. {
  40. RELATIONSHIP People("L1");
  41. People.CreateBaby("L2");
  42. clrscr();
  43. People.Display_People();
  44. People.Display_Baby();
  45. People.Display_Baby_Baby();
  46. getch();
  47. return 0;
  48. }