0

I have two functions with the signatures as below.

void overloading(int, int)

and

void overloading(int, A *ptr, int)

where A is a class.

When I am compiling in gcc 3.4. My main function has the following call.

A *pointer = new A();

overloading(10, pointer,20);

I get an error which says

"Invalid conversion from A * to int" 

Am I doing something wrong or the compiler is not able to identify the correct overloaded function?

3
  • 4
    Post real code please - this should work. Your problem is likely somewhere else. Commented Jul 1, 2013 at 15:24
  • Can you post a minimal code sample that reproduces the problem? BTW that is a seriously old compiler, people might struggle to reproduce the problem. Commented Jul 1, 2013 at 15:26
  • Any chance the second definition prototype is not being included in the code that claims improper params? Commented Jul 1, 2013 at 15:26

1 Answer 1

2

Your problem is that at the location you may the call to overloading you haven't declared the three parameter version of the function so the compiler only sees the (int, int) version. You can even prove this by pre-processing the source file (for example g++ -E).

Just make sure to include all the needed headers in your main file.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 No surprise that I support this answer, given my comment in the general section. I would highly suspect this is accurate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.