delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/24/09:35:47

Message-ID: <3631E505.4773CBD3@montana.com>
Date: Sat, 24 Oct 1998 08:32:37 -0600
From: bowman <bowman AT montana DOT com>
X-Mailer: Mozilla 4.5b2 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: construction has been delayed due to somebody's stupidity (most
likely my own)
References: <5zeY1.843$SI2 DOT 270 AT news DOT cwix DOT com> <gunaalubzrpbz DOT f1bmi21 DOT pminews AT news DOT avnl1 DOT nj DOT home DOT com>
Reply-To: djgpp AT delorie DOT com


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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019