LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Operator Overloading problem (https://www.linuxquestions.org/questions/programming-9/operator-overloading-problem-196704/)

ashwinipahuja 06-23-2004 03:52 AM

Operator Overloading problem
 
Hi
following piece of code gives error under g++.


#include<iostream>
using namespace std;


class A
{
public:
int operator()() const;
operator int() const;
};
int A:perator()() const
{
return 0;
}
int A:perator int() const
{
return 0;
}
int main()
{
return 0;
}



Error Message:-

undefined.cpp:16: return type specified for `operator int'
undefined.cpp:22:2: warning: no newline at end of file
:confused:

dakensta 06-23-2004 05:59 AM

Quote:

undefined.cpp:16: return type specified for `operator int'
The error is that you have specified a return type in the definition of your user defined cast.

Remove it and the code will compile.


All times are GMT -5. The time now is 08:15 PM.