LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-18-2005, 08:00 AM   #1
asmith
LQ Newbie
 
Registered: May 2004
Location: bulgaria
Posts: 8

Rep: Reputation: 0
pointer to member problem with gcc 3.4.3


Code:
class ctemp
{
public:
     typedef void (ctemp::*ttemp)(int);

     ttempmptr;
     ctemp()
     {
           mptr = &ctemp::func;
     }
     void func(int a)
     {
            printf("hehe %d\n", a);
     }
     void callit()
     {
           (this->*mptr)(0);
     }
};

void main()
{
     ctemptmp;
     tmp.mptr = &ctemp::func;
     (tmp.*mptr)(0);
     tmp.callit();
}
When I try to compile it with gcc 3.4.3 it stops and says:
-"error: `mptr' undeclared (first use this function)" in the line with (tmp.*mptr)(0);

I've tried the same code in the visualc 7.1 and it compiled immediately...

Can someone help, I think that I've missed some command line switch, because I'm sure that is impossible gcc to lack such a standard feature...as member to pointer...

Any ideas will be appreciated... and sorry for the bad english...

Last edited by asmith; 01-18-2005 at 08:09 AM.
 
Old 01-18-2005, 08:40 AM   #2
allawos
LQ Newbie
 
Registered: Dec 2004
Location: Toulouse (FRANCE)
Posts: 9

Rep: Reputation: 0
Hello ... just an idea ...

isn't it :

(*(tmp.mptr))(0);

that should be used ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
c to GCChange of member functions in iostream from GCC296 to Gcc 3.2.2 Basiltp Programming 0 11-29-2004 03:19 PM
LQ member progress status from member to senior member............. emailssent LQ Suggestions & Feedback 3 10-11-2004 01:31 PM
C++ Pointer altered on a member funcion call moyacuba Programming 6 04-02-2004 07:45 PM
C++ pointer to downcast member function Wondre Programming 12 02-21-2003 02:56 AM
c++ Pointer to Member Function Wondre Programming 0 02-15-2003 06:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration