how to overload (int) for my class?

Hi I have a class that it have an integer attribute and I want when it typed for example :
class myclass{
private:
int salary;
}
int main(){
myclass o();
int x =(int) o;
}
x get loaded with o.salary;
please tell me what should I do?
I don't really get your question there.... repost pls...
You can overload the conversion operator:
1
2
3
4
operator int () const
{
    return salary;
}
( member of the class )
Topic archived. No new replies allowed.