GNU & Borland Pure Virtual Functions.
Jason McDonald
jasonm@telefloratech.com
Mon Feb 12 08:56:00 GMT 2001
Hi,
Why would GNU report an error with this code and Borland Builder would not?
#include <iostream.h>
#include <string.h>
class A{
public:
char temp[10];
virtual void from(char *s) { cout << "FROM A";}
virtual void blank(void) = 0;
virtual ~A(){};
};
class B: public A{
public:
virtual void from(char *s) { strcpy(temp,s);}
virtual void blank(void) { cout << "BLANK B";}
virtual ~B(){};
};
B doingB(char *s)
{
B b;
b.from(s);
return b;
}
void printit(A &a)
{
cout << a.temp << " YADA\n";
}
int main(void)
{
printit(doingB("THIS"));
return 0;
}
GNU error:
>a.c: In function `int main ()':
>a.c:34: could not convert `doingB()' to `A &'
>a.c:28: in passing argument 1 of `printit (A &)'
Thanks for your help.
Jason.
More information about the Gcc
mailing list