Mail Archives: djgpp/1998/10/24/09:10:06
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 -