I inclue the file but the function could not be seen

Hi every one
I really appreciate If you can help me in this problem.
I have a page called s.cpp with a function in it called "calculate" like below
 
 float Sim::calculate(float e){}


As I want to use it in another page called p.cpp I include s.h on the c.pp
but when I wrote down the name of function it is not recognized

1
2
3
4
5
6
7
8
                        if(x!=-1)
			{
				.....//some codes
			}
			else
			{
                               float newE = calculate(e); 
			}


Can you guess why it is not recognized?
Thank you in advance for any comments
Probably because you didn't add s.cpp to your project or compile line so the linker couldn't find the implementation.
Are you talking about a compile-time error, or a link-time error?

If you have error messages, then tell us what those errors are. I cannot understand why you thought it would be better to withhold that information from us!
Thank you for your response. It is a link-time error and it is said : "Function 'calculate' could not be resolved". I use Eclipse for write down codes
Thanks jlb for your comment.
What is compile line?
all of my files is in one project.
One obvious thing is that you've defined your function as:

float Sim::calculate(float e){}

What is Sim? A namespace? A class?

The snipped of calling code you've shown us doesn't give us any clue about how it knows that it's looking for the function in something called Sim.
Last edited on
Sim is the class that is defined in the h file of the s page
And that bit of code you've shown us that tries to call calculate() - is that part of the class too?

Because if it isn't, then the code is trying to call a free function called calculate(), which is not the same thing as Sim::calculate().
class Sim {
public:
float calculate(float e)
}
yes it is defined in this s.h page
I'm asking about the code that calls calculate(). It needs to call that method on an object of type Sim. Where is that object?
Topic archived. No new replies allowed.