You are here:

C++/undefined reference

Advertisement


Question
Hello Zlatko.
I'm doing a program in c++ but I've some difficulties since I'm new to it.
In my main() code I'm using a function find() that must use another function helper(),like:

void main(){...
 result=find();
 ...
}

void find(){...
 result_1=helper(object);
 ...
}

and helper must return more than one value,so I've defined a helper.h:

struct Characteristics{
 int result1,result2;
}
Characteristics helper(object);

and the helper.cpp that includes helper.h.Also the main includes helper.h.
Now when I'm compiling i get the error from main that tells me of an undefined reference to helper(object)
Can you please help me?
Thanks in advance

Answer
Hi Luis
It is difficult to know what the problem is because you have left out so much of the code. I suppose that
Characteristics helper(object);
should have the type of the object specified.
For example:
Characteristics helper(SomeType object);
That may fix the problem.

Also the struct should end with a semicolon as shown below
struct Characteristics{
int result1,result2;
}; // Don't forget the semicolon.

If you cannot fix the problem, send your files as attachments to zlatko.c.help at gmail.com and I will look at it before the end of my day.

Best regards
Zlatko

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2016 About.com. All rights reserved.