delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/08/17:47:24

From: nil AT hem1 DOT passagen DOT se (Nicklas Lindgren)
Newsgroups: comp.os.msdos.djgpp
Subject: static members
Date: Wed, 08 Jul 1998 20:29:07 GMT
Organization: Algonet/Tninet
Lines: 48
Message-ID: <35a3d453.7807828@news.algonet.se>
NNTP-Posting-Host: du93-5.ppp.algonet.se
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have made a class with a static member. The code compiles alright
but i get linking errors saying that they are undefined references.

Maybe i missed something. Here's the code:

//----intrface.h
...
class Interface {
protected:
  GraphicsInterface *gi;
  DataFile *data;
  Config *config;
public:
  Interface();
  virtual Interface *Update();
  virtual void Render();
  void SetGraphicsInterface(GraphicsInterface *Gi);
  void SetDataFile(DataFile *Data);
  void SetConfig(Config *C);
  static Interface killer; // ****** here it is
};

//----intrface.cc
...
#include "intrface.h"
...
Interface *InterfaceText::Update() {
  if (!key[KEY_ESC]) {
    return (this);
  }
  else {
    return (&killer); // ****** link error
  }
}

//----ticker.cc
...
#include "interface.h"
...
void Engine(Interface *I) {
  Interface *interface = I;
  do {
    interface = interface -> Update();
    interface -> Render();
  } while (interface != &Interface::killer); // ****** link error
}

	Nicklas Lindgren

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019