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

Message-ID: <3631DF43.4D49212F@montana.com>
Date: Sat, 24 Oct 1998 08:08:03 -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>
Reply-To: djgpp AT delorie DOT com


Jason Glass wrote:
> 
> anyways, could somebody please tell me what's going on..  thanks a bunch.


lose the parens and things will go better. Note that in the following
snippet, you
could leave the parameterless ctor out completely and the default ctor
would work, if
there was no declaration of a ctor with parameters. I would say your
other compilers are
broken, but I'm not a C++ language lawyer.


<------------------------------- snippet 
----------------------------------->
#include <iostream.h>

class MyClass {

public:
	MyClass() {};
	MyClass(int val);
	int get_data();
	void put_data(int val);
protected:
	int data;
};

MyClass::MyClass(int val) {

	data = val;
}

int MyClass::get_data(void) {
	return data;
}

void MyClass::put_data(int val) {
	data = val;
}

int main(void) {

	MyClass junk;
	MyClass more_junk(4321);
	
	junk.put_data(1234);
	cout << "junk = "  << junk.get_data() << endl;
	cout << "more_junk = " << more_junk.get_data() << endl;
	return 0;
}

- Raw text -


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