c++ - about operator overloading -


My professor asks me to ask which operators can not overload C ++ and what is the reason for this. I found that dot (.), Scope resolution (: :), conditional (?), Size () operators can not be overloaded. Can anyone tell me the reason for this?

struct troll {int money = 0; Int problems = 0; Float cant_touch_this = 0.0; Integer & amp; Operator (const std :: string and member_name) {if (member_name == "money") return problems; And if (member_name == "problem") refund; And if (member_name == "cant_touch_this") cant_touch_this; And throw 0; }}; Int main () {TrollT; T. Money = 42; T.problems = 3; }

The above snippet is not compiled correctly while typing , I asked myself a lot of questions:

  • what
  • What parameters should this take?
  • How do I handle cases where I throw?
  • Why do I need a runtime overhead to evaluate the compiled time member?
  • Will other developers be relieved by switching my members with my developers?
  • This list may proceed ...

    This is due to the number of reasons why you can not overload the dot (.) Operator, and similarly There are questions that are trying to load more overload operator than you.

    A smart mind can find a decent answer to these questions, but this mind has not been created so far, C ++ is not a member of the committee, not a fan of the standard feature offer or just care Not because he does not need this feature.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -