Archived

This topic is now archived and is closed to further replies.

Class problem

This topic is 5015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My buddy is writing a program: http://www.geocities.com/a_hyrulian_hero/trialCpp.zip I think he''s trying to pass a variable through a class. When we compile it, we get this error: C:\DOCUME~1\KELLYA~1\LOCALS~1\Temp\ccIrbaaa.o(.text+0x24):main.cpp: undefined reference to `Head::Init(Tail)'' I''m using Dev C++ Could someone please let me know whats going on? Thanks a lot!

Share this post


Link to post
Share on other sites
it''s a linker error. you are trying to call to a function "Head::Init(Tail)" that you haven''t actually definied in your code.

my guess is that you did something like this:


class Head
{
public:
void Init(Tail foo);
}
};

void Init(Tail foo)
{
//do some stuff;

}


i.e. you forgot "Head::" in frontof the Init definition:

should have been:


void Head::Init(Tail foo)
{
//do some stuff

}


-me

Share this post


Link to post
Share on other sites
You need to first compile each (cpp) module independently (generating object files) and only then link them together (generating an executable).


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan


[edited by - Fruny on March 19, 2004 7:57:55 PM]

Share this post


Link to post
Share on other sites