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

C/C++ Q/A
[4446] 이 에러가 왜 나는 건지 모르겠어요. 좀 가르쳐 주세요.
삽질호야 [smh81] 1566 읽음    2004-05-21 11:04
책에 있던 예제인데요. 에러가.. ㅡㅡ;;

왜 나는 건가요?

밑에 2/3지점 쯤에 // 있는 부분에 봐주세욤.. 부탁드립니다. ^^

#include <iostream.h>
#include <iomanip.h>
#include <process.h>
#include "queue.h"

enum Bool {False, True};

class GraphNode{
friend class Graph;
private:
  int vertex;
  GraphNode* link;
public:
  GraphNode(int v, GraphNode* l=0) : vertex(v), link(l){};
};

class Graph{
private :
  int size;
  Bool* visited;
  GraphNode** graph;
  GraphNode** tail;
public :
  Graph(int sz);
  ~Graph();
  void ReadGraph(int[][2], int);
  void PrintGraph();
  void DFS();
  void DFS(int);
  void BFS(int);
  void Components();

};

Graph::Graph(int sz)
{
size=sz;
graph=new GraphNode*[size];
tail=new GraphNode*[size];
for(int i= 0; i<size; ++i)graph[i]=tail[i]=0;
}

Graph::~Graph()
{
GraphNode *p, *q;
for(int i=0; i<size; ++i){
  p=graph[i];
  q=p->link;
  while(1){
   if(!p) break;
   else{
    delete p;
    p=q;
    if(q) q=q->link;
   }
  }
}
delete[] graph;
delete[] tail;
}

void Graph::ReadGraph(int edge[][2], int n)
{
int v, w;
GraphNode *nodev, *nodew;
for(int i=0; i<n; ++i){
  v=edge[i][0];
  w=edge[i][1];
  nodev=new GraphNode(v);
  nodew=new GraphNode(w);
  if(!tail[v])graph[v]=tail[v]=nodew;
  elsetail[v]=tail[v]->link=nodew;
  if(!tail[w])graph[w]=tail[w]=nodev;
  elsetail[w]=tail[w]->link=nodev;
}
}

void Graph::PrintGraph()
{
for(int i=0; i< size; ++i){
  cout << setw(3) << i << " -> ";
  for(GraphNode *p=graph[i]; p; p=p->link){
   cout << p-> vertex;
   if(p->link) cout << " -> ";
  }
  cout << endl;
}
}

void Graph::DFS()
{
visited = new Bool[size];
for(int i=0; i<size; ++i) visited[i] = False;
DFS(0);
delete[] visited;
}

void Graph::DFS(const int v)
{
visited[v] = True;
cout << v << " ";
for(GraphNode *p=graph[v]; p; p=p->link)
  if(!visited[p->vertex]) DFS(p->vertex);
}

void Graph::BFS(int v)
{
visited=new Bool[size];
for(int i=0; i<size; i++) visited[i]=False;
visited[v]=True;
Queue<int> q;                                   // 여깁니다. 여기~~ 111 번
q.Insert(v);                                    // 112번줄. 밑에 에러메시지 써놨습니다.
while( !q.IsEmpty() ){            
  v= q.Delete();
  cout << v << " ";
  for(GraphNode *p=graph[v]; p; p=p->link)
   if( !visited[p->vertex] ){
   q.Insert(p->vertex);
   visited[p->vertex]=True;
  }
}
delete[] visited;
}

void Graph::Components()
{
visited = new Bool[size];
for(int i=0; i<size; i++) visited[i]=False;
for(int i=0; i<size; i++)
  if( !visited[i]){
   cout << "\n 연결요소 : ";
   DFS(i);
}
delete[] visited;
}

void main()
{
int EdgeMat[12][2]={{0,1},{0,2},{1,3},{1,4},{2,5},{2,6},{3,7},{4,7},{5,8},{6,8},{7,9},{8,9}};
int DisConGraph[7][2]={{0,1},{0,3},{1,2},{2,3},{4,5},{4,6},{5,6}};
Graph g(10), c(7);
g.ReadGraph(EdgeMat, 12);
c.ReadGraph(DisConGraph, 7);
cout << "연결그래프 \n";
g.PrintGraph();
cout << "\n깊이 우선 탐색 방문 순서 : ";
g.DFS();
cout << "\n너비 우선 탐색 방문 순서 : ";
g.BFS(0);
cout << "\n\n비연결 그래프 \n";
c.PrintGraph();
c.Components();
}


에러내용입니다.

111: Undefined symbol 'Queue' in function Graph::BFS(int)
111: Expression syntax in function Graph::BFS(int)
112: Undefined symbol 'q' in function Graph::BFS(int)

뭐가 잘못 되었는지 제발좀 가르쳐 주세요.. 감사합니당.

에디트플러스로 작성해서 볼랜드 C++ 컴파일러를 사용했습니당.


+ -

관련 글 리스트
4446 이 에러가 왜 나는 건지 모르겠어요. 좀 가르쳐 주세요. 삽질호야 1566 2004/05/21
4447     Re:이 에러가 왜 나는 건지 모르겠어요. 좀 가르쳐 주세요. 김시환 1405 2004/05/21
4450         Re:Re: 이렇게 했더니 no file names given... 이라는 메시지가 뜹니다. 삽질호야 1595 2004/05/21
4457             Re:Re:Re: 이렇게 했더니 no file names given... 이라는 메시지가 뜹니다. 김시환 1484 2004/05/24
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.