Mail Archives: djgpp/1998/09/24/10:00:18
From: | jfvschra AT eduserv1 DOT rug DOT ac DOT be (Johan Verschraegen)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Gcc bug?
|
Date: | 24 Sep 1998 13:54:25 GMT
|
Organization: | University of Ghent, Belgium
|
Lines: | 52
|
Message-ID: | <6udiuh$f9p$1@inf6serv.rug.ac.be>
|
NNTP-Posting-Host: | eduserv1.rug.ac.be
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I use gcc from djgpp to compile the following C++ program under DOS. I
get two warnings: (1)assuming & on 'Test::PrintMode0()' and
(2)assuming & on 'Test::PrintMode1()'
There's also an error: (3)in method 'void Test::Print()'
must use .* or ->* to call printer-to-member
function in 'Test::PrintPtr(...)'
When i tried to compile to program with gcc under Unix i got no errors and
the program worked fine. Please help me with how to solve this.
//begin of the program
#include <stdio.h>
class Test
{
int testint;
void (Test::*PrintPtr)();
public:
Test(int in_testint)
{
testint=in_testint;
}
void SetMode(int mode)
{
if(mode==0) PrintPtr=PrintMode0; <-(1)first warning
if(mode==1) PrintPtr=PrintMode1; <-(2)second warning
}
void PrintMode0()
{
printf("mode 0: %d\n", testint);
}
void PrintMode1()
{
printf("mode 1: %d\n", testint);
}
void Print()
{
PrintPtr(); <-(3) here i get the error
}
};
int main()
{
Test test1(10);
test1.SetMode(0);
test1.Print(); //This should print 10
return 0;
}
- Raw text -