home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19685 < prev    next >
Encoding:
Text File  |  1993-01-21  |  2.3 KB  |  89 lines

  1. Path: sparky!uunet!gatech!asuvax!ncar!hsdndev!husc-news.harvard.edu!husc.harvard.edu!robison1
  2. From: robison1@husc10.harvard.edu (Keith Robison)
  3. Newsgroups: comp.lang.c++
  4. Subject: Linking problem with static member
  5. Keywords: static, liner, Sun
  6. Message-ID: <robison1.727639814@husc.harvard.edu>
  7. Date: 21 Jan 93 18:10:14 GMT
  8. Lines: 78
  9. Nntp-Posting-Host: husc10.harvard.edu
  10.  
  11. I'm having a small problem with a static member function which
  12. I wish to declare in the class (and .h file) but wish to 
  13. define in a .cc file (so that it goes in a .o file).  This
  14. code compiles fine, but I get a linking error when done.
  15.  
  16. ld: Undefined symbol 
  17.    KERBioseqFormatGuide::newGuide(SeqFormat) 
  18.  
  19.  
  20. Any help will be appreciated.
  21.  
  22. Thanks.
  23.  
  24. Keith Robison
  25. Harvard University
  26. Department of Cellular & Developmental Biology
  27. Department of Genetics / HHMI
  28.  
  29. robison@biosun.harvard.edu 
  30.  
  31.  
  32.  
  33.  
  34. // The class definition:
  35. class KERBioseqFormatGuide 
  36. {
  37.  public:
  38.   enum SeqFormat {unknownFormat, /* for auto-detection of formats */
  39.           genbankFormat, /* GenBank/EMBL/DDBJ flatfile format */
  40.           fastaFormat,   /* FASTA/Pearson format */
  41.           ncbiServerFormat,  /* NCBI E-mail server Swiss-Prot */
  42.           gcgFormat,     /* GCG format */
  43.           swissprotFormat
  44.          };
  45.  
  46.  protected:
  47.     SeqFormat currentFormat;
  48.  private:
  49.     const SeqFormat selfFormat;
  50.     
  51.  public:
  52.    KERBioseqFormatGuide(SeqFormat ownFormat) 
  53.     : currentFormat(ownFormat), selfFormat(ownFormat) 
  54.     {} // cout<<"creating format#"<<(int) identifySelf()<<endl; /*dbg*/};
  55.    virtual  ~KERBioseqFormatGuide() {};
  56.  
  57.    inline SeqFormat identifySelf() const;
  58.    SeqFormat identifyCurrent() const;
  59.     int needsChanging() const;
  60.    static KERBioseqFormatGuide* newGuide 
  61.     (KERBioseqFormatGuide::SeqFormat newFormat);
  62.  ...
  63. }
  64.  
  65.  
  66. //the .cc file: -- putting "static" here makes no difference
  67.  KERBioseqFormatGuide* KERBioseqFormatGuide::newGuide 
  68.     (KERBioseqFormatGuide::SeqFormat newFormat)
  69. {
  70.    KERBioseqFormatGuide* guidePt;
  71.    switch (newFormat)
  72.      {
  73.      case  KERBioseqFormatGuide::fastaFormat:
  74.        guidePt = new KERFastaFormatGuide();
  75.        break;
  76.      case  KERBioseqFormatGuide::genbankFormat:
  77.        guidePt = new KERGenbankFormatGuide();
  78.        break;
  79.      case  KERBioseqFormatGuide::swissprotFormat:
  80.        guidePt = new KERGenbankFormatGuide();
  81.        break;
  82.  
  83.      default:
  84.        guidePt = new KERUnknownFormatGuide();
  85.        break;
  86.      }
  87.     return guidePt;
  88.  }
  89.