#include "stdafx.h"
#include <iostream>
using namespace std;
class distance {
int feet;
float inches;
public :
distance ():feet(0),inches(0)
{};
distance(float in,int ft): feet(ft),inches(in)
{};
void getdist()
{cout<<"enter the values of feeet and inches ";
cin>> feet>>inches;}
void showdist()
{cout<<"feet= "<<feet<<"\n inches="<<inches;}
distance add_dis(distance);};
distance distance::add_dis(distance d2)
{ distance temp;
temp.inches= inches+d2.inches;
if(temp.inches>=12.0)
temp.inches-= 12.0;
temp.feet=1;
temp.feet+=feet+d2.feet;
return temp;
}
int _tmain(int argc, _TCHAR* argv[])
{
distance d1,d3;
distance d2(5,2.3);
d1.getdist();
d3=d1.add_dis(d2);
d1.showdist();
d2.showdist();
return 0;
}
the errors are as follows
1>------ Rebuild All started: Project: muqeet3, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'muqeet3', configuration 'Debug|Win32'
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>muqeet3.cpp
1>c:\users\muqeet\documents\visual studio 2005\projects\muqeet3\muqeet3\muqeet3.cpp(25) : error C2872: 'distance' : ambiguous symbol
1> could be 'c:\users\muqeet\documents\visual studio 2005\projects\muqeet3\muqeet3\muqeet3.cpp(9) : distance'
1> or 'c:\program files (x86)\microsoft visual studio 8\vc\include\xutility(1652) : iterator_traits<_Iter>::difference_type std::distance(_InIt,_InIt)'
1>c:\users\muqeet\documents\visual studio 2005\projects\muqeet3\muqeet3\muqeet3.cpp(46) : error C2872: 'distance' : ambiguous symbol
1> could be 'c:\users\muqeet\documents\visual studio 2005\projects\muqeet3\muqeet3\muqeet3.cpp(9) : distance'
1> or 'c:\program files (x86)\microsoft visual studio 8\vc\include\xutility(1652) : iterator_traits<_Iter>::difference_type std::distance(_InIt,_InIt)'
1>c:\users\muqeet\documents\visual studio 2005\projects\muqeet3\muqeet3\muqeet3.cpp(47) : error C2872: 'distance' : ambiguous symbol
1> could be 'c:\users\muqeet\documents\visual studio 2005\projects\muqeet3\muqeet3\muqeet3.cpp(9) : distance'
1> or 'c:\program files (x86)\microsoft visual studio 8\vc\include\xutility(1652) : iterator_traits<_Iter>::difference_type std::distance(_InIt,_InIt)'
1>c:\users\muqeet\documents\visual studio 2005\projects\muqeet3\muqeet3\muqeet3.cpp(47) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
1>Build log was saved at "file://c:\Users\muqeet\Documents\Visual Studio 2005\Projects\muqeet3\muqeet3\Debug\BuildLog.htm"
1>muqeet3 - 3 error(s), 1 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========