class Registrar{
public:
Registrar();
~Registrar();
static void Register(Function*);
protected:
static BTree *Functions;
};
The class itself works, all the functions are error free. However, when the code is compiled and then linked, There is a Linker error saying "Unresolved External ''Registrar::Functions''"
I don''t understand why this is, because Functions is a variable (a binary Tree) whose class is defined above this implementation. all it''s functions work, and I have used that code before.
Can anyone help me?
--Josh
Unresolved External, what external?
Hello,
I have built a class that looks like this:
Do you define the "Functions" variable in the cpp file with the method implementations? I think you need:
in a source file somewhere. The C++ FAQ explains it better than I do - Why are classes with static data members getting linker errors?
Edited by - Krunk on December 30, 2001 6:23:59 PM
BTree *Registrar::Functions;
in a source file somewhere. The C++ FAQ explains it better than I do - Why are classes with static data members getting linker errors?
Edited by - Krunk on December 30, 2001 6:23:59 PM
ah, so I need that line also,
Yes, It works now, Many thanks!
EXCELLENT
Many, Many thanks
I mentioned something earlier about Access Violations, But I've figured that out now, after re-reading the article posted here.
Many thanks!
--Josh
Edited by - JoshG on December 30, 2001 6:40:43 PM
Edited by - JoshG on December 30, 2001 6:43:44 PM
Yes, It works now, Many thanks!
EXCELLENT
Many, Many thanks
I mentioned something earlier about Access Violations, But I've figured that out now, after re-reading the article posted here.
Many thanks!
--Josh
Edited by - JoshG on December 30, 2001 6:40:43 PM
Edited by - JoshG on December 30, 2001 6:43:44 PM
I can`t think of any reason that Functions being static would cause access violations. The only thing that imediately springs to mind is that you have a static pointer to a BTree. If you don`t create a BTree at some point and put its address in Functions then you`ll be in trouble
This is beside the point, but you might want to avoid calling a binary tree a BTree. A B-Tree is a general multiway(not binary) tree.
Fantastic doctrines (like Christianity or Islam or Marxism or Microsoft-bashing) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
Fantastic doctrines (like Christianity or Islam or Marxism or Microsoft-bashing) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
quote:Original post by JoshG
Hello,
I have built a class that looks like this:
class Registrar{ public: Registrar(); ~Registrar(); static void Register(Function*); protected: static BTree *Functions;};
The class itself works, all the functions are error free. However, when the code is compiled and then linked, There is a Linker error saying "Unresolved External 'Registrar::Functions'"
I don't understand why this is, because Functions is a variable (a binary Tree) whose class is defined above this implementation. all it's functions work, and I have used that code before.
Can anyone help me?
--Josh
To properly answer your question, regarding the error, Why don't you try giving a type to Function* in the Register( Function* ) something along the line of:
static void Register( void Function* );
except that you should replace the void in front of Function* to what ever type is required. That should probably solve your problem.
"And that's the bottom line cause I said so!"
Cyberdrek
Resist Windows XP's Invasive Production Activation Technology!
"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash
Edited by - cyberdrek on January 1, 2002 1:50:28 AM
Sorry I think you may have missunderstood.
"Function" IS a type. It''s defined by the code:
But there was no problem in that code, Just the declaration of the BTree was wrong. But all is good now, I have finished developing that code now.
It was actually a part of a Game Console, that section handled taking input, finding the right function to run, running it, and outputing what needed to be outputed.
I also designed it so that new functions could be added easily by making a small declaration just after the code for a function.
Thanks for all your help, and like I said. All errors are gone now!
"Function" IS a type. It''s defined by the code:
typedef void (*Function)(char*);
But there was no problem in that code, Just the declaration of the BTree was wrong. But all is good now, I have finished developing that code now.
It was actually a part of a Game Console, that section handled taking input, finding the right function to run, running it, and outputing what needed to be outputed.
I also designed it so that new functions could be added easily by making a small declaration just after the code for a function.
Thanks for all your help, and like I said. All errors are gone now!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement