Mail Archives: djgpp/1998/10/24/09:35:47
Mike Ruskai wrote:
>
> Well, the first thing I have to say is that your example does not demonstrate
> the problem you indicate when I try to compile it, with no less than four
> compilers (IBM VisualAge C++, Borland C++, GNU GCC, and DJGPP).
yeah, but try the non-trivial snippet for interesting errors:
<------------------------- badcode.cpp ---------------------->
#include <iostream.h>
class MyClass {
public:
MyClass();
void say_hi(void);
protected:
int data;
};
void MyClass::say_hi(void) {
cout << "hello world\n";
}
int main(void)
{
MyClass instance(); // point of interest
instance.say_hi();
}
<--------------------------- end: badcode.cpp
----------------------->
or, for another variation on the theme,
<--------------------------- stillbad.cpp
----------------------------->
#include <iostream.h>
class MyClass {
public:
MyClass();
void say_hi(void);
protected:
int data;
};
void MyClass::say_hi(void) {
cout << "hello world\n";
}
int main(void)
{
MyClass instance; // point of interest
instance.say_hi();
}
<------------------------------ end: stillbad.cpp
-------------------------->
this one actually compiles and executes under gcc. I don't know if the
proir two will
make it through any compiler, but I would be suspicious of a compiler
that did accept them.
<------------------------------ end: thisworks.cpp
-------------------------->
#include <iostream.h>
class MyClass {
public:
MyClass() {};
void say_hi(void);
protected:
int data;
};
void MyClass::say_hi(void) {
cout << "hello world\n";
}
int main(void)
{
MyClass instance(); // point of interest
instance.say_hi();
}
<------------------------------ end: thisworks.cpp
-------------------------->
- Raw text -