D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] C++ segmentation faults



What might cause a segmentation fault? I've got a small C++ file which has 
two base classes, then a main class called Day which inherits from both base 
classes. In the nature of the program, I need to have a maximum of 31 days 
each including an array of up to 9 integer values. Sounds small.

Yet when I enlarge the scope of the program I get segmentation faults. If I 
keep it down to a small number of instances, it's OK. When I create a second 
class called Week that also inherits both base classes. When I create an 
instance of this second class, I get segmentation faults. (Apart from the 
name, it's a straight copy of the Day class).

When these faults happen, just omitting one instance prevents the error:
Day *day1 = new Day(1,2,3,4,5,6,7);

Does g++ use a memory model? Do I have to use another option to avoid 
segmentation faults?

(Anyone who can help, I can send the code.)

The thing is, the program needs to be enlarged to cope with a full 365 days. 
!!

-- 

Neil Williams

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly