From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30179 invoked by alias); 1 Dec 2007 16:01:40 -0000 Received: (qmail 30171 invoked by uid 22791); 1 Dec 2007 16:01:40 -0000 X-Spam-Check-By: sourceware.org Received: from mu-out-0910.google.com (HELO mu-out-0910.google.com) (209.85.134.189) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 01 Dec 2007 16:01:36 +0000 Received: by mu-out-0910.google.com with SMTP id g7so1225787muf for ; Sat, 01 Dec 2007 08:01:32 -0800 (PST) Received: by 10.86.66.1 with SMTP id o1mr6923528fga.1196524889180; Sat, 01 Dec 2007 08:01:29 -0800 (PST) Received: by 10.86.95.4 with HTTP; Sat, 1 Dec 2007 08:01:29 -0800 (PST) Message-ID: <8bc817ee0712010801rac0bd23se0695766866e9e0f@mail.gmail.com> Date: Sat, 01 Dec 2007 16:01:00 -0000 From: "Tom Browder" To: "Michael Sullivan" Subject: Re: Undefined References Cc: gcc-help@gcc.gnu.org In-Reply-To: <1196524150.9670.4.camel@camille.espersunited.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8bc817ee0711302043t7eefb94eub6423ca23a449175@mail.gmail.com> <1196515626.25419.26.camel@camille.espersunited.com> <8bc817ee0712010622ibcb277fya1c7374a66e64cec@mail.gmail.com> <1196519300.25393.27.camel@camille.espersunited.com> <8bc817ee0712010645w6efd39bey1d3b4931e36f1183@mail.gmail.com> <8bc817ee0712010726v7fbba8b0kfa548a547128661d@mail.gmail.com> <1196523242.9670.2.camel@camille.espersunited.com> <8bc817ee0712010742x773a01f9k791137226ddf07e7@mail.gmail.com> <8bc817ee0712010744ibda3e90qd634b6b8aecfa4f2@mail.gmail.com> <1196524150.9670.4.camel@camille.espersunited.com> X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2007-12/txt/msg00031.txt.bz2 On Dec 1, 2007 9:49 AM, Michael Sullivan wrote: ... > Is this right? ... > because when I make, I still get errors... ... > battle.o: In function `battle::battle()': > battle.cpp:(.text+0x9e3): undefined reference to Right--undefined. I forgot I've been messing with your code and had defined the Character() constructor. I'm not sure about all the rules, but I think you have several choices. Since you declared the default constructor, you must define it. If you don't declare it, it will be provided automatically and that may not be what you want. Choices: + don't declare it + declare it private, don't define it //header: private: Character(); + declare it public, define it as noop //header: public: Character(){} + declare it public, define it with actions //header: public: Character(); //cpp Character::Character() { name[0] = 0; maxHP = 0; maxMP = 0; currentHP = 0; currentMP = 0; } The latter is what I did. Ideally you can clean up your constructors by organizing member variables and using initializer syntax, etc. Other improvements for modern code include using STL strings, etc. I highly recommend Scott Meyers' books--much food for though. -Tom