LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 06-23-2004, 03:52 AM   #1
ashwinipahuja
Member
 
Registered: Mar 2004
Posts: 79

Rep: Reputation: 15
Question 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 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, 05:59 AM   #2
dakensta
Member
 
Registered: Jun 2003
Location: SEUK
Distribution: Debian & OS X
Posts: 194

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


Reply


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 08:58 AM
c++ [] operator overloading exodist Programming 12 04-17-2004 03:06 PM
C# with dotGNU, operator overloading exodist Programming 2 03-15-2004 05:52 PM
Builtin operator overloading. exodist Programming 15 03-11-2004 10:41 PM
C++ overloading extraction operator petercool Programming 5 09-06-2003 06:35 AM


All times are GMT -5. The time now is 08:06 AM.

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