
hi folks
Please explain me why C++ done have return type for casting operator? I have googled, understood that its special case and some points, still I am not clear about why compiler dont give error since casting operators not follow general function syntax and does casting operator different from operator overload?
Thanks in advance
Code:
#include<iostream>
using namespace std;
class paise
{
float p ;
public:
paise(int x =0):p(x){}
~paise(){}
operator int()
{
cout<<"convertint"<<endl;
return p;
}
};
void print(int x)
{
cout<<"paise="<<x<<endl;
}
int main()
{
paise a(4.78);
print(a);
return 0;
}