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 4613230
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:31:03+00:00 2026-05-22T01:31:03+00:00

In C#, the method(function) of overloading any operator must be static and public .

  • 0

In C#, the method(function) of overloading any operator must be static and public.

I see that making it static is a good thing, every object doesn’t need its own version of it.

But in C++, it doesn’t have to be static. Why does C# enforce this and C++ doesn’t?

What are the advantages and disadvantages of both designs?

  • 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-05-22T01:31:04+00:00Added an answer on May 22, 2026 at 1:31 am

    why C++ Doesn’t enforce operator overloading to be “Static” ?
    If you make overloaded operator function static it wont have access to this. One would need access to this inside the overloaded function, as usually the function would change the state of this.

    You can make a overloaded operator function static if you don’t need access to this inside that function, which essentially means you are not manipulating the state of the object on which the operator function was invoked. So it is opssible but not usual or essentially desired.

    Making an globally overloaded operator function static would limit the scope of the operator function to the same file.

    Given the both above, Compiler doesn’t enforce overloaded operator functions to be static since enforcing it would provide no real advantage or convenience, rather not enforcing the same provides more convenience.

    why C# enforces operator overloading to be “Static” ?
    This explains it much better than I can.

    What are the advantages and disadvantages?
    Well, the answer to the first Question does say out when one could make a overloaded operator function static & that explains the advantage/disdvantage.

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

Sidebar

Related Questions

Why don't more mainstream statically typed languages support function/method overloading by return type? I
Is there a built-in function/method that can check if a given string is a
The only way I know to do function/method overloading is by way of the
Possible Duplicate: Operator Overloading in PHP I am trying to create a library that
Given the following Flash method: function sendToJava(name:String, ... args) { ExternalInterface.call(sendCommand, name, args); }
I understand overriding a method/function redefines its implementation in the derived class from its
Can someone give me a real-world scenario of a method/function with a string argument
In an actionscript function (method) I have access to arguments.caller which returns a Function
Looking for a nifty helper function/method for grepping through all defined tables, columns, stored
Do you write one test per function/method, with multiple checks in the test, or

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.