On Thu, 20 Sep 2001, Federico Sevilla III wrote:
> $ g++ -Wall -o mp mp.cpp
> ...
> It's interesting to note that none of these return errors, and it doesn't
> matter whether I use g++ or gcc despite the fact that the program uses
> classes.
gcc is just a wrapper program: give it a *.c program and it does a
c-compile. Give it a *.C, *.cpp *.cxx program and it does a c++ compile.
There is nothing unusual about that. Also that fact that no compile
time error is reported does not mean that the program will work!
> Using what very little I know of gdb, I "debugged"[1] it and found that it
> segfaults in card::value_(),
Most segfaults are results of using a pointer as if it were pointing to
something when it is not pointing to anything yet. Typical code looks
like this:
char *p;
strcpy(p, "I am a C programmer");
Since p is not pointing to anything yet, this will produce a segfault.
Of course this is an over-simplified example, but I think your c++ code
is hiding something this simple.
> My hunch is that things are breaking with my pointers. In particular I
> have an array of pointers to "class card". I use pointers instead of
> simply "class card"s so that I can subsequently change any element by
> deleting it then creating a new card.
Are you pointers pointing to anything when you assign to them?
Do you have a properly defined "operator="?
Do you have a proper copy constructor, card(const card& x)?
PMana
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]
To subscribe to the Linux Newbies' List: send "subscribe" in the body to
[EMAIL PROTECTED]