Hi all! here is my code(converting float to distance). i try to use operator to solving that. But it cannot work. So please tell me where is wrong!
#include<iostream.h>
#include<conio.h>
It's more conventional to do the conversion in a constructor, using an operator is ok I guess. The real problem is your conversion algorithm is incorrect.
The assignment operator doesn't make sense. I'm not sure where to begin. First, conceptually an assignment operator should be used for assigning objects of the same type. Secondly, in your assignment operator you create and return a temporary object without modifying the actual object that you are trying to assign to which does nothing useful. operator= is invoked for dist1 but you don't even attempt to modify dest1. You need to use
this->feet and this->inches to modify the object.
Start with this tutorial on classes and read both parts. You'll have to search the web for other articles and threads on assignment operators because you are misunderstanding the concept. http://cplusplus.com/doc/tutorial/classes/