dclemans@mntgfx.mentor.com (Dave Clemans @ APD x1292) (05/27/89)
(This refers to version 1.35.0+ of G++)
The following example compiles fine under C++:
class xyz
{
int a1;
int b2;
int c3;
int d4;
public:
xyz()
{
a1 = 1;
b2 = 2;
c3 = 3;
d4 = 4;
}
~xyz()
{
}
int a() { return a1; }
int b() { return b2; }
int c() { return c3; }
int d() { return d4; }
};
xyz testing;
xyz testing2;
void main()
{
xyz onstack;
int i;
i = testing2.c() + testing.a() + onstack.b();
}
If I try to compile it under g++, I get...
[262]$ g++ tt.c
In method void xyz::~xyz ():
tt.c:19: parse error at end of input
tt.c:32: parse error before `{'
tt.c:32: warning: Old style parameter specification frowned upon
tt.c:19: parm types given both in parmlist and separately
tt.c:36: `testing' was not declared (first use this function)
tt.c:36: (Each undeclared identifier is reported only once
tt.c:36: for each function it appears in.)
But if the xyz destructor has its implementation moved out of the class
definition, g++ handles it fine. I.e.
class xyz
{
int a1;
int b2;
int c3;
int d4;
public:
xyz()
{
a1 = 1;
b2 = 2;
c3 = 3;
d4 = 4;
}
~xyz();
int a() { return a1; }
int b() { return b2; }
int c() { return c3; }
int d() { return d4; }
};
xyz::~xyz() { }
xyz testing;
xyz testing2;
void main()
{
xyz onstack;
int i;
i = testing2.c() + testing.a() + onstack.b();
}
dgcsacco@eileen.samsung.com (Joe Sacco) (05/28/89)
In article <1989May26.150134.24068@mntgfx.mentor.com>, dclemans@mntgfx.mentor.com (Dave Clemans @ APD x1292) observes :
There is a problem in the placement of the destructor definition in his
example. ......
There was a similar problem with unions. Both of these problems seem to
have vanished in 1.35.1-. I've installed the patches for 1.35.1- and
have found that both versions of Dave's example now compile and run.
JOE