Skip to main content
gamedev.net
🔒 Locked

Member pointers (Solved)

Started by The C modest god Sep 25, 2006 at 2:13 AM 5 replies 850+ views
Original Post
The C modest god
The C modest god
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]
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
michaweyel
michaweyel
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.
michaweyel
michaweyel
oh, misread it...sorry, my bad.
The C modest god
The C modest god
Ok, My brother helped me, it should be:

(this->*Ptr)();

It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
The C modest god
The C modest god
Quote:
Original post by Anonymous Poster
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


The 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.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
Emmanuel Deloget
Emmanuel Deloget
@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 Poster
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


This 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" list

This 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,

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.