Hi all...first time poster, long time reader.
I've been experiencing some strange behavior on a Linux development system (Red Hat 5) compiling a C++ App. I've tried to reduce the source to something as simple as possible so that I can fit all source that would still causes my problem. Below are the three simple source files for class FooClass:
FooClass.hpp:
FooClass.cpp
main.cpp
I get no compiler errors but everytime i run this, I get a segmentation fault. The fault happens at the point when I try to initialize a member of the data structure, FooStruct (see line 6 in FooClass.cpp: foo->fooData = 5; )
Please help as I am stumped.
Oh...and for a side note, this runs with no problem on a different system running an older version of Linux (Red Hat 4).
Thanks in advance!
I've been experiencing some strange behavior on a Linux development system (Red Hat 5) compiling a C++ App. I've tried to reduce the source to something as simple as possible so that I can fit all source that would still causes my problem. Below are the three simple source files for class FooClass:
FooClass.hpp:
Code:
class FooClass
{
public:
[INDENT]void fooMethod();[/INDENT]
private:
[INDENT]typedef struct {[/INDENT]
[INDENT][INDENT]int fooData;[/INDENT][/INDENT]
[INDENT]} FooStruct;[/INDENT]
};
FooClass.cpp
Code:
#include "FooClass.hpp"
void FooClass::fooMethod()
{
[INDENT]FooStruct* foo;[/INDENT]
[INDENT]foo->fooData = 5;[/INDENT]
}
main.cpp
Code:
#include "FooClass.hpp"
int main(int argc, char** argv)
{
[INDENT]FooClass* foo = new FooClass();[/INDENT]
[INDENT]foo->fooMethod();[/INDENT]
[INDENT]delete foo;[/INDENT]
[INDENT]return 0;[/INDENT]
}
I get no compiler errors but everytime i run this, I get a segmentation fault. The fault happens at the point when I try to initialize a member of the data structure, FooStruct (see line 6 in FooClass.cpp: foo->fooData = 5; )
Please help as I am stumped.
Oh...and for a side note, this runs with no problem on a different system running an older version of Linux (Red Hat 4).
Thanks in advance!