Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-23-2004, 04:52 AM   #1
Registered: Mar 2004
Posts: 79

Rep: Reputation: 15
Question Operator Overloading problem

following piece of code gives error under g++.

using namespace std;

class A
int operator()() const;
operator int() const;
int Aerator()() const
return 0;
int Aerator 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
Old 06-23-2004, 06:59 AM   #2
Registered: Jun 2003
Location: SEUK
Distribution: Debian & OS X
Posts: 194

Rep: Reputation: 35
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem compiling with overloading method 'operator<<' freeindy Programming 4 04-29-2005 09:58 AM
c++ [] operator overloading exodist Programming 12 04-17-2004 04:06 PM
C# with dotGNU, operator overloading exodist Programming 2 03-15-2004 06:52 PM
Builtin operator overloading. exodist Programming 15 03-11-2004 11:41 PM
C++ overloading extraction operator petercool Programming 5 09-06-2003 07:35 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:57 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration