C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[49568] 프로그램 전체입니다! 오류 메세지가 뜨는데 도대체 모르겠네요. 좀 봐주세요!!
홍순규 [kinghong] 1283 읽음    2007-06-07 02:04
pet.h 헤더파일



#include <iostream.h>



class Pet
{
public:
  typedef char PetName[20];
  enum PetType {Dog, Cat, Monkey};

private:
  PetType kind;  // 종류
  PetName name;  // 이름

public:
  Pet (PetType x= Dog, char* n =" "); //생성자

  PetType Type(void) {return (kind); }  //종류를 반환
  char* Name(void) {return (name); }  //이름을 반환

  void Input(void); //입력
  void Sintro(void); //자기소개
};

ostream& operator << (ostream& s, Pet& p); //문자열 출력 연산자



petlist.h 헤더파일



#include <iostream.h>
#include "pet.h"

//클레스

class PetNode
{
friend class PetList;

private:
  Pet* pet; //애완동물 데이터
  PetNode* next;

public:
  PetNode(Pet* ptr) : pet(ptr) {next=NULL;} //생성자
  ~PetNode(void)     {delete pet;}

  PetNode* Next(void)    {return (next);}
  operator Pet*(void)    {return (pet);}

class PetList
{
friend ostream& operator <<(ostream& s, PetList& x);

private:
  PetNode* top; //선두 노드로의 포인트
  PetNode* bottom; // 마지막 더미노등로의 포인트

public:
  PetList(void); //생성자
  ~PetList(void); //소멸자

  PetNode* Top(void) { return ((top == bottom) ? NULL : top); }
  PetNode* Bottom(void);

  PetList& Insert(PetNode*); //선두에 노드 삽입
  PetList& Append(PetNode*);
  PetList& Delete(void);
  PetList& Remove(void);
  PetList& Clear(void);

  PetList& Introduce(void);
};





pet.cpp 파일



#include <string.h>
#include "pet.h"

//생성자
Pet::Pet(PetType t, char* n)
{
kind=t;
strcpy(name,n);
}

void Pet::Input(void)
{
int k;

do {
   cout << "종류 [0.개, 1.고양이, 2.원숭이]:";
   cin >> k;
} while (k < Dog || k > Monkey);
kind = PetType(k);
cout << "이름:" ;
cin >> name;
}

//자기소개

void Pet::Sintro(void)
{
cout << "나는";
switch (kind) {

case Dog :  cout << "개"; break;
case Cat :  cout << "고양이"; break;
case Monkey : cout << "원숭이"; break;
}

cout <<"이고, 이름은 " << name << "입니다!!\n";
}

//애완동물 클레스 문자영 출력 연산자

ostream& operator << (ostream& s, Pet& p)
{
s<< "{";

switch (p.Type()){
case Pet::Dog  :s<<"개";    break;
case Pet::Cat  :s<<"고양이"; break;
case Pet::Monkey :s<<"원숭이"; break;
}
s<< p.Name() <<"}";
return(s);
}



petlist.cpp 파일



#include <iostream.h>

#include "petlist.h"

//생성자
PetList::PetList(void)
{
Pet* x = new Pet(Pet::Dog,"DUMMY");
top = bottom = new PetNode(x);
}

//해제자

PetList::~PetList(void)
{
Clear(); //모든 요소 삭제
delete top; //더미 노드 해제

}

// 리스트의 마지막 요소로의 포인터

PetNode* PetList::Bottom(void)
{
if (top == bottom)
  return (NULL);
else{
   PetNode* ptr = top;
   while (ptr -> next != bottom)

    ptr = ptr -> next;
    return (ptr);
}
}

//리스트의 선두에 요소를 삽입

PetList& PetList::Insert(PetNode*x)
{
PetNode* ptr =top;
top = x;
top -> next =ptr;
return (*this);
}

//리스트의 마지막에 요소를 추가
PetList& PetList::Append(PetNode* x)
{
if(top == bottom)
  Insert(x);
else{
   PetNode* ptr = Bottom();
   ptr -> next = x;
   x -> next = bottom;
}
return (*this);
}

//리스트의 선두요소 삭제
PetList& PetList::Delete(void)
{
if(top !=bottom){
   PetNode* ptr=top ->next;
   delete top;
   top = ptr;
}
return (*this);
}

//리스트의 마지막 요소 삭제
PetList& PetList::Remove(void)
{
if(top == bottom);
else if (top->next ==bottom)
Delete();

else{
   PetNode* now = top;
   PetNode* pre;
   while (now->next != bottom) {
    pre = now;
    now = now ->next;
   }
   pre->next=bottom;
   delete now;
}
return (*this);
}

// 리스트의 모든 요소 삭제
PetList& PetList::Clear(void)
{
PetNode* ptr = top;
while (ptr != bottom){
  PetNode* next = ptr -> next;
  delete ptr;
  ptr = next;
}
top = bottom;
return (*this);
}

//자기소개
PetList& PetList::Introduce(void)
{
PetNode* ptr = top;
cout <<"<<-----------자기소개----------->>\n";
while (ptr !=bottom){
  ptr -> pet -> Sintro();
  ptr = ptr -> next;
}
cout <<"<<------------------------------->>\n";
return (*this);
}

//petlist stream 삽입 연산자
ostream& operator <<(ostream& s, PetList& x)
{
PetNode* ptr = x.top;
s<<"{\n";
while (ptr != x.bottom) {
  s<<'\t'<<*(Pet*)(*ptr)<<'\n';
  ptr = ptr->Next();
}
S<<"}\n";
return (s);
}
     
main.cpp



#include <iostream.h>
#include "petlist.h"

enum Menu{
Terminate, Insert, Append, DspFirst, DspLast, Delete,
Remove, Clear, Print, Intro, MenuOver
};

Menu SelectMenu(void) // 메뉴선택
{
int ch;

do{
  cout<< "(1) 선두에 삽입  (2) 마지막에 추가"
   << "(3) 선두를 표시  (4) 마지막을 표시\n";
  cout<< "(5) 선두를 삭제  (5) 마지막을 삭제"
   << "(7) 모두 삭제    (8) 모두 표시\n";
  cout<< "(9) 리스트순 자기소개 (0) 종료\n";
  cin>> ch;
} while (ch < Terminate || ch >= MenuOver);
return ((Menu)ch);
}

int main(void)
{
  Menu menu;
  PetList list;

  do{
   menu = SelectMenu();
   switch (menu){
   PetNode* p;
   case Insert : { cout <<"선두에 삽입할 데이터를 입력하시오\n";
         Pet* x = new Pet();
         x -> Input();
         PetNode* n = new PetNode(x);
         list.Insert(n);
       } break;
   case Append : { cout <<"마지막에 추가할 데이터를 입력하시오\n";
       Pet* x = new Pet();
       x ->Input();
       PetNode* n = new PetNode (x);
       list.Append(n);
        }break;
   case DspFirst : if(p = list.Top())
        ((Pet*)*p)->Sintro();
       break;
   case DspLast : if (p = list.Bottom())
          ((Pet*)*p)->Sintro();
       break;
   case Delete  : list.Delete(); break;
   case Remove  : list.Remove(); break;
   case Clear   : list.Clear();  break;
   case Print   : cout << list;  break;
   case Intro   : list.Introduce(); break;
   }
  } while (menu != Terminate);
  return(0);
}




컴파일시



Compiling...
main.cpp
c:\program files\microsoft visual studio\myprojects\last\main.cpp(4) : error C2059: syntax error : 'PCH creation point'
c:\program files\microsoft visual studio\myprojects\last\main.cpp(4) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
c:\program files\microsoft visual studio\myprojects\last\main.cpp(9) : error C2059: syntax error : 'PCH creation point'
c:\program files\microsoft visual studio\myprojects\last\main.cpp(10) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
c:\program files\microsoft visual studio\myprojects\last\main.cpp(24) : error C2059: syntax error : 'PCH creation point'
c:\program files\microsoft visual studio\myprojects\last\main.cpp(25) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
c:\program files\microsoft visual studio\myprojects\last\main.cpp(60) : fatal error C1004: unexpected end of file found
Error executing cl.exe.




이런 에러가 뜹니다.. ㅠㅜ 왜그러는지 수정 좀 부탁 드립니다!!!

+ -

관련 글 리스트
49568 프로그램 전체입니다! 오류 메세지가 뜨는데 도대체 모르겠네요. 좀 봐주세요!! 홍순규 1283 2007/06/07
49569     Re:프로그램 전체입니다! 오류 메세지가 뜨는데 도대체 모르겠네요. 좀 봐주세요!! 장성호 1427 2007/06/07
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.