if i dont use distance::distance d1(1.5) and rather use just distance d1(1.5), i get a series of error messages:Code:// To convert meter to feet and inch #include <iostream> using namespace std; const float M = 3.25; class distance { private: int feet; float inch, meter; public: distance() {} ~distance() {} distance(float a) { meter = a; float k = meter*M; feet = int(k); inch = (k-feet) * 12.0; } void show() { cout << feet << " feets " << inch << " inches" << endl; } }; int main() { distance::distance d1(1.5); d1.show(); system("pause"); return 0; }
I:\C++\Lab 7\1a.cpp||In function `int main()':|
I:\C++\Lab 7\1a.cpp|32|error: use of `distance' is ambiguous|
I:\C++\Lab 7\1a.cpp|10|error: first declared as `class distance' here|
i:\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\. .\..\..\..\include\c++\3.4.5\bits\stl_iterator_bas e_funcs.h|115|error: also declared as `typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)' here|
I:\C++\Lab 7\1a.cpp|32|error: `distance' was not declared in this scope|
I:\C++\Lab 7\1a.cpp|32|error: expected `;' before "d1"|
I:\C++\Lab 7\1a.cpp|33|error: `d1' was not declared in this scope|
||=== Build finished: 6 errors, 0 warnings ===|