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

C/C++ Q/A
[82] [Q] GCC로는 컴파일되는데 BCB로는 에러가 나요.
김상우 [] 2135 읽음    2001-12-02 17:31
NNLib-0.1.tar.gz 0B Neural Network Source Files
Neural Network 관련 연산 라이브러리 소스코드를
가져다가 Compile하는데, 에러가 납니다.

별루 복잡하지 않은 코드인데, 왜 bcb에서는 에러가 나는지 모르겠어요.
컴파일러에 대해서 잘 아시는분은 한 번 지적해 주시면 감사하겠습니다.

나오는 Error Message는 아래와 같습니다.

[C++ Error] graph.h(70): E2462 'virtual' can only be used with non-template member functions
[C++ Error] graph.h(70): E2303 Type name expected
[C++ Error] graph.h(70): E2139 Declaration missing ;


아래의 일련의 소스코드중에 제일 마지막에 나오는 다음의 코드에서 나온 에러입니다.
임시방편으로 virtual keyword를 없애면 Type name expected Error나오면서 ostream을 인식못한것 처럼 보입니다. 그치만 include에서 iostream을 했기 때문에 문제 없어야 하는데.
ostream이 Template class인지는 모르겠지만, 어쩋든 GCC에선 되는데.
첨부파일로 이 라이브러리 전체 소스를 첨부합니다. 한번 해 봐주시면 감사.


  /* streaming helpers: do nothing, since we do not have additional data */
  virtual ostream &writeTo(ostream &o) {return o;}
  istream &readFrom(istream &i) {return i;}
  static istream& dummyRead(istream &i) {return i;}



/* In file Unit1.cpp */
#include "nn_base.h"

int main(int argc, char* argv[])
{
   MLP x(60, 60, 1, 0.1);

   return 0;
}
/* End of file Unit1.cpp */

/* In file nn_base.h */
#ifndef _NN_H_
#define _NN_H_

#include <vector>
#include <set>
#include <stdexcept>
#include <math.h>
#include <iostream>
#include "graph.h"

...

/* End of file nn_base.h */

/* In file graph.h */
#ifndef _GRAPH_H_
#define _GRAPH_H_

#include <set>
#include <map>
#include <string>
#include <iostream>

/* forward declaration */
class Link;

/*
  this class implements the basic node of a graph:
  - it keeps track of links in & out of itself
  - it can remember local changes
*/
class Node {
private:
  std::set<Link*> nextS;            /* the set of link leaving this node */
  std::set<Link*> prevS;            /* the set of link entering this node */
public:
  typedef std::set<Link*> Links;        /* just a convenience */
protected:
  bool changed;                    /* true if some changes has occurred */
public:

  Node():nextS(),prevS(),changed(true) {};    /* a new node has no links, but it has changed */
  virtual ~Node() {};                /* just a placeholder */

  /* link management functions: non-virtual, since all the working of the node depends
      on the semantic of these.
      they return true if successful.
  */
  bool link_to(Link* l) {            /* add an outward link */
     set_changed();
     return nextS.insert(l).second;
  }
  bool unlink_to(Link* l) {            /* remove an outward link */
     set_changed();
     return nextS.erase(l) >=1;
  }
  bool link_from(Link *l) {            /* add an inward link */
     set_changed();
     return prevS.insert(l).second;
  }
  bool unlink_from(Link *l) {            /* remove an inward link */
     set_changed();
     return prevS.erase(l) >=1;
  }

  /* change management methods */
  bool is_changed() {return changed;}
  virtual void set_changed(bool s=true) {changed=s;}    /* virtual, because derived classes
                                (e.g. Neuron) need to add functionality */

  /* accessors (to allow use of iterators, mostly) */
  const std::set<Link*> &next() {return nextS;}
  const std::set<Link*> &prev() {return prevS;}

  /* streaming helpers: do nothing, since we do not have additional data */
  virtual ostream &writeTo(ostream &o) {return o;}
  istream &readFrom(istream &i) {return i;}
  static istream& dummyRead(istream &i) {return i;}
};

...
/* End of file graph.h */

+ -

관련 글 리스트
82 [Q] GCC로는 컴파일되는데 BCB로는 에러가 나요. 김상우 2135 2001/12/02
107     황당한 해결 김상우 2161 2001/12/05
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.