gerry@TOADWAR.UCAR.EDU (gerry wiener) (03/22/89)
Compiling following program taken from C++Programming by John Berry (pg22)
generates a core dump using g++-1.34.1 on sun4-os4:
hail:gerry:1>g++ p22.c
In function int main ():
p22.c:25: Segmentation violation
Program c++ got fatal signal 11.
hail:gerry:2>
If x.area is replaced by x.area() and y.area is replaced by y.area()
it compiles correctly.
-------------------------------------------------------------------------------
#include <stream.h>
struct square
{
int side;
void set(int);
int area();
};
void square::set(int x)
{
side = x;
}
int square::area()
{
return(side*side);
}
main()
{
square x, y;
x.set(2);
cout << "area of square x = " << x.area << "\n";
y.set(3);
cout << "area of square y = " << y.area << "\n";
}