bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with C++ method pointers


From: Artak Avetyan
Subject: Re: Problem with C++ method pointers
Date: Tue, 13 Mar 2001 19:37:11 -0800

Many bugs are here. Follow notes - "^^^".
First change the code, then retry.  Not sure that this is g++ compiler error.

Regards,
Artak.


> ////////////////////////////////////////////////////////////////////////////////
> #include <stdio.h>
> #include <iostream.h>
>
> class Macro
> {
>   public:
>   io_init(FILE** fp);
> };
>
> typedef void (Macro::*fncPtr)(int);
>
> struct Jug
> {
>   fncPtr fp;
>   char *p;
>   char* q;
> };
>
> main()
> {
>   Jug jug [] = {
>                 {&(Macro::io_init), "howdy", "dude!"},
>               };

 ^^^^^^^^^^^^^^
1) Incorrect init., use:  Jug jug[] = {{(Macro::io_init), "howdy", "dude!"}}
2) don't think good idea to use Macro::io_init - non static funtion, better
  Macro mac;
Jug jug[] = {{(mac.io_init), "howdy", "dude!"}}

>   FILE** fp;
>   if (!strcmp(jug[0].p, "howdy")) {
>     jug[0].fp(fp);              // <<<<<< **** error line. ****

^^^^^^^^^^^^^^^^^
incorrect call, right code is
(mac.*(jug[0].fp))(fp);

>
>   }
> }
>
> Macro::io_init(FILE** fp)
> {
>   cout << "howdy" << endl;
> }
> ////////////////////////////////////////////////////////////////////////////////
>
> The error msg is like so....
> ravik $ g++ c.cc
> c.cc: In function `int main()':
> c.cc:28: Internal compiler error.
> c.cc:28: Please submit a full bug report to address@hidden'.
>
> Cheers,
>
> Ravi Kumar                                      ph: 408 341 5136
> Design Verification Engineer,                   address@hidden
> HAL Computer Systems.
>
> _______________________________________________
> Bug-gplusplus mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-gplusplus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]