Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:13:32+00:00 2026-06-09T20:13:32+00:00

I found the URL below that says that If an operator can be used

  • 0

I found the URL below that says that

 If an operator can be used as either a unary or a binary 
 operator (&, *, +, and -), you can overload each use separately.

I am working with g++ in Linux and I tried the following and it didn’t compile.

int operator+ (const int a,const int b){
   std::cout << "MINE"<<std::endl;
   return 0;
}

int main(){
   char c='c';
   std::cout << c+2 << std::endl;
}

The error says

error: ‘int operator+(int, int)’ must have an argument 
of class or enumerated type

I was willing to play and see in action the Integer Promotion Rules.

Am I doing something wrong or that URL is valid only for MS or I misunderstood the promotion rule?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:13:33+00:00Added an answer on June 9, 2026 at 8:13 pm

    The error message indirectly tells you what you need to know — you are not permitted to overload operators (binary or unary) that act only on built-in types.

    For a user-defined type T, you can separately overload binary + (for example by T operator+(T lhs, T rhs)) and unary + (for example by T operator+(T t)). You could also define operator+(T lhs, int rhs), but you can’t overload addition of two integers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In most of the musical site i found that, they use to write below
I found out that the FormWizard only __init__ 's once, when the url is
I need a regular expression that would let me validate Url. I found this
I've been looking around JQuery libraries for the URL hash, but found none that
I used the codes below to load image NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@file://home/%@, filename]]; NSImage
How can I fix the script below so that it will work EVERY TIME!
I'm using the code I found below to get the thumbnail url of a
I found difficulty to load image from url in every 30 seconds in android
I found this code on the internetz, it checks the current page url; function
Test Page URL: http://www.guygar.com/inception/ultra/indexCopy.html I am new to this and searching SO I found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.