   Member pointers (Solved)
  I am trying to do the following:template <class T>class Something {   public:  Somthing() { this->Ptr = Somthing<T>::Method; };  T * (Somthing::*Ptr)();  T var;  T * Method() {return &this->var;};  T * foo () { return this->Ptr(); //<= Compilation error};}But I get a compilation error that the term does not evaluate to a 0 variables function.How is it supposed to be done?Thanks in advance.[Edited by - The C modest god on September 25, 2006 2:59:14 AM]
  hmmmm...I'm not exactly sure what you are trying to do, but the reason why you get this error is probably because your class "something" doesn't have a function called Ptr(), which is what you are trying to call in the line where you get the error.   ;  oh, misread it...sorry, my bad.   ;  Ok, My brother helped me, it should be:(this->*Ptr)();;  never again:- post source code that isn't self-contained- post source code that doesn't contain comments about what you are trying to do- post source code that doesn't even compile due to TYPOS- post source code that you didn't even verify before posting;Quote:Original post by Anonymous Posternever again:- post source code that isn't self-contained- post source code that doesn't contain comments about what you are trying to do- post source code that doesn't even compile due to TYPOS- post source code that you didn't even verify before postingThe problem is that I don't program on this computer.I hope you didnt try to run this code and it formatted your computer or somthing like this.   ;  @TCMG: since you try to play with pointers to members, you should read the corresponding section in the C++ FAQ Lite. Everything should be clearer then. Quote:Original post by Anonymous Posternever again:- post source code that isn't self-contained- post source code that doesn't contain comments about what you are trying to do- post source code that doesn't even compile due to TYPOS- post source code that you didn't even verify before postingThis is pretty harsh. What about this one?never again: - assume that a user has access to a compiler on the machine he uses to browse gamedev- use a tone that make the OP thinks that he broke some invisible rules in a way that will probably lead him to a painfull death- require that the OP add comments to an obvious 12 line long piece of code (or point at lines that are not obvious and request explainations)- post a "never again" listThis is not a "l33t xp3r7 0nlY" maling list, this is a public forum designed to be useful to beginners. The question of The C modest god is well formed (code, error, question about how it should be done (not a "do this for me" kind of question)), and as such cannot be dismissed like you did. This is rude. If you don't understand the problem, post a question, not a set of what you think are the requirement to be allowed to post on gamedev.Thanks for your patience,   