home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!asuvax!ncar!hsdndev!husc-news.harvard.edu!husc.harvard.edu!robison1
- From: robison1@husc10.harvard.edu (Keith Robison)
- Newsgroups: comp.lang.c++
- Subject: Linking problem with static member
- Keywords: static, liner, Sun
- Message-ID: <robison1.727639814@husc.harvard.edu>
- Date: 21 Jan 93 18:10:14 GMT
- Lines: 78
- Nntp-Posting-Host: husc10.harvard.edu
-
- I'm having a small problem with a static member function which
- I wish to declare in the class (and .h file) but wish to
- define in a .cc file (so that it goes in a .o file). This
- code compiles fine, but I get a linking error when done.
-
- ld: Undefined symbol
- KERBioseqFormatGuide::newGuide(SeqFormat)
-
-
- Any help will be appreciated.
-
- Thanks.
-
- Keith Robison
- Harvard University
- Department of Cellular & Developmental Biology
- Department of Genetics / HHMI
-
- robison@biosun.harvard.edu
-
-
-
-
- // The class definition:
- class KERBioseqFormatGuide
- {
- public:
- enum SeqFormat {unknownFormat, /* for auto-detection of formats */
- genbankFormat, /* GenBank/EMBL/DDBJ flatfile format */
- fastaFormat, /* FASTA/Pearson format */
- ncbiServerFormat, /* NCBI E-mail server Swiss-Prot */
- gcgFormat, /* GCG format */
- swissprotFormat
- };
-
- protected:
- SeqFormat currentFormat;
- private:
- const SeqFormat selfFormat;
-
- public:
- KERBioseqFormatGuide(SeqFormat ownFormat)
- : currentFormat(ownFormat), selfFormat(ownFormat)
- {} // cout<<"creating format#"<<(int) identifySelf()<<endl; /*dbg*/};
- virtual ~KERBioseqFormatGuide() {};
-
- inline SeqFormat identifySelf() const;
- SeqFormat identifyCurrent() const;
- int needsChanging() const;
- static KERBioseqFormatGuide* newGuide
- (KERBioseqFormatGuide::SeqFormat newFormat);
- ...
- }
-
-
- //the .cc file: -- putting "static" here makes no difference
- KERBioseqFormatGuide* KERBioseqFormatGuide::newGuide
- (KERBioseqFormatGuide::SeqFormat newFormat)
- {
- KERBioseqFormatGuide* guidePt;
- switch (newFormat)
- {
- case KERBioseqFormatGuide::fastaFormat:
- guidePt = new KERFastaFormatGuide();
- break;
- case KERBioseqFormatGuide::genbankFormat:
- guidePt = new KERGenbankFormatGuide();
- break;
- case KERBioseqFormatGuide::swissprotFormat:
- guidePt = new KERGenbankFormatGuide();
- break;
-
- default:
- guidePt = new KERUnknownFormatGuide();
- break;
- }
- return guidePt;
- }
-