static menber pointer to member function - LNK2001 error

Tech-Archive recommends: Speed Up your PC by fixing your registry



For some reason the code below will not link using the .NET linker. I get a
LNK2001 error: unknown external.

The wierd part is that if I remove LINE A, it compiles fine, with the LINE
C implemented in header file and LINE D commented out. If I remove LINE A,
and comment out implementation of LINE C, and use the implementation at LINE
D, it won't compile. It doesn't like LINE B, and doesn't seem to call for a
definition outside of the class, like most static members.

Help.

#include "Tester.h"

main(){
Tester testerx;
testerx.test(); /////////////LINE A
};

Tester.h:
===========
#include "xyz.h"
//int xyz::*p; /////////////////LINE B
class Tester{
public:
//constructor
Tester();
~Tester();
void test(){xyz::p=testX::geti;}//////////LINE C
};
Tester.cpp:
===================
#include "Tester.h"
Tester::Tester(){};
Tester::~Tester(){};
//void Tester::test(){xyz::p=testX::geti;}; /////////////LINE D
xyz.h:
=====================
#include "testx.h"
class xyz
{
public:
xyz(void);
~xyz(void);
static int (testX::*p)(); ////////////LINE E
};
xyz.cpp:
=======================
#include "xyz.h"
xyz::xyz(void){}
xyz::~xyz(void){}

testx.h:
======================
class testX{
public:
int i;
int geti();
void seti(int);
testX(){};
};
testx.cpp:
===================
#include "testx.h"
int testX::geti(){return i;}
void testX::seti(int ii){i=ii;}
.



Relevant Pages

  • Re: Loading single word to a xmm register
    ... And you know the reason why?... ... As long as i have written an Assembler that compiles ... optimize the Routine at the Code Level intensively, ...
    (alt.lang.asm)
  • Re: Passing return value by reference
    ... The only reason it compiles on VC is ... That's the immediate reason for the error message, ... C++ permits non-constant member function calls on temporary objects. ...
    (comp.lang.cpp)
  • RE: x11/nvidia-driver on Sept07 snapshot
    ... I've given it a shot and it compiles ... fine, kldloads fine, but doesn't detect graphics card ... for some reason ...
    (freebsd-current)
  • Re: State of WORKING-STORAGE in Statically-Called Subroutines
    ... Boy it is much easier when there is no good reason to have any static calls. ... I work at an environment where Endevor compiles all programs before they go into ... If the shop compiler requires static calls, we are in a bit more danger - not ...
    (comp.lang.cobol)