C¿Í C++°ü·Ã |
---|
Á¦¸ñ | Re: ´äº¯ 1998/07/04 (14:14) |
À̸§ | ±èÈ¿¿ø |
¹øÈ£ | 4 |
Á¶È¸ | 660 |
º»¹® |
include<iostream> #include<string> struct{ string name; int number; Item*next; Item() :next(NULL){} ---->ÀÌ°Ô ´ëü ¹» ¶æÇϴ°ÇÁö... constructor·Î, next¸¦ NULL·Î ÃʱâÈ }; class List{ Item*head; public: List():head(NULL){} ------->ÀÌ°Ç ¶Ç ¹» ¸»ÇÏ´Â °ÇÁö... constructor·Î, head¸¦ NULL·Î ÃʱâÈ ~List(); ---------------->ÀÌ°Ç ¿Ö ±»ÀÌ ¾²´Â °ÇÁö... destructorÀε¥, delete() functionÀÌ µé¾î°¡¾ß ÇÔ. bool AddItem(Item*ptr); void PrintList(); }; List::~List(){ -------------->¿©±â¼´Â destructor Á¤ÀǸ¦ ³»·Á¾ß Çϴµ¥ ¾î¶»°Ô Ç϶ó´Â °ÇÁö. } bool List::AddItem(Item*ptr){ -------------->¿©±â´Â»õ·Î¿î µ¥ÀÌŸ¸¦ Áý¾î ³Ö´Âµ¥, ¾Æ¸¶µµ Á¤·ÄÀ» ÇÏ¸é¼ ³Ö´Âµí. ---->¿©±â¼ boolÀº ¿Ö ¾²¿´½À´Ï±î? Á¦´ë·Î Ãß°¡°¡ µÇ¾ú´ÂÁö¸¦ ¾Ë¾Æº¸±â À§ÇÏ¿©, return °ªÀ» true or false·Î ¼³Á¤ } void List::PrintList(){ } main(){ List phonenumber; for(int i=0;i<10;i++){ Item*p= new Item(); .... |