• ### Announcements

#### Archived

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

# Class problem

## 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 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 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]

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627665
• Total Posts
2978524

• 10
• 10
• 12
• 22
• 13