68 237
Assignments Done
99%
Successfully Done
In November 2018

Answer to Question #21132 in C++ for users

Question #21132
what is the error in this programme, please help?

#include<iostream.h>
#include<conio.h>
class calculation
{
public:

void calc(int i,int j)
{
cout<<"i="<<i<<" j="<<j;
}

void calc(int i,float j)
{
cout<<"\ni="<<i<<" j="<<j;
}
};
void main()
{
clrscr();

calculation p;
p.calc(10,20);

p.calc(20,10.4);

getch();
}
Expert's answer
1. Use <iostream> header instead of <iostream.h>
#include <iostream>
2. Add this line before class declaration:
using namespace std;
3. The calc method is called with parameters of type (int, double)
and compiler doesn't know what method to choose: (int, int) or (int, float).
So the second parameter has to be either int or float.
Since you need to pass the floating point value you should use the following method call:
p.calc(20, 10.4f);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
27.12.12, 14:57

You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

SWQuadris
26.12.12, 23:20

Thanks 4 d solution!!!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions