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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:25:01+00:00 2026-05-17T19:25:01+00:00

full disclosure – this is for a homework assignment. And I normally would not

  • 0

full disclosure – this is for a homework assignment. And I normally would not ask for homework help, but here it is.

I’m asked to provide 5 examples of “overloading implicit in c++”. I’m sure he is referring to operator overloading for types such as char, int, float, etc in iostream and the types themselves.

I understand explicitly overloading an operators such as (my dumb example)

class Vegetables {
    public:
        Vegetables();
        ~Vegetables();
        Vegetables& operator+ (Vegetables&);
        Vegetables& operator- (Vegetables&);
    private:
        int beans;
        ... // more veggies here
};

Vegetables& Vegetables::operator+ (Veggies&) {
    beans += Veggies.beans;
    ...
    return *this;
}

So I am just trying to decide if he is referring to the overloading that is “implicit” when adding types. For example, int+double. I think what actually occurs is int gets cast as a double, then the double + operator is used and a double is returned? Of course, the way this happens varies based on if it is a value assignment or in iostream or other i/o method, etc. But my point remains…

  • 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-17T19:25:01+00:00Added an answer on May 17, 2026 at 7:25 pm

    .

    It’s late. I’m tired. But this is intriguing…

    “overloading implicit in c++” is far from clearcut.

    This smacks of someone creating their own terminology. Perhaps they are merely unable to view their own writings from a third-party perspective and are therefore being obtuse. More than likely, your teacher is busy with his own research projects (or other work), and is doing the absolute minimum effort required to teach you. It sucks. You pay a lot of money and you’re treated horribly. I’ve been there myself. All I can say is, get used to it. Or find a better school. And next time, read the homework ASAP, and ask your teacher! If enough folks bother him, wasting his time, he’ll get his act together.

    Next thought: Try google. Always your friend.

    My thoughts: He may be talking about overloaded functions that are automatically (implicitly) created, such as the copy constructor. Consider:

    class Foo
    {
    public:
      int i;
      Foo(int argI) : i(argI) { }
      //Foo( const Foo & argFoo ) : i(argFoo.i) { }
    };
    
    int
    main()
    {
      Foo f(2),g(3);
      Foo h = f;
    }
    

    With the copy constructor commented out, you will find only f(2) and g(3) invoke Foo(int). The Foo h=f line is correctly initializing h through an implicit copy constructor that overloads Foo(int). (Caveat Emptor: I’m still stuck using the outdated gcc/g++ 3.4.4 & 4.0.1. Your mileage with your compiler may vary…)

    You might also get some mileage out of subclassing, as copy constructors and operator=() are not inherited, and new implicit versions are created.

    Another thought: As (everyone) has already mentioned, your instructor may be thinking of how types are converted. For instance, we could initialize g(3.2) using a floating point value. It would be converted to an int, and work with Foo(int). (Depending on your compiler settings, you might [should!] get a warning about loss of precision.)

    We can go the other way too. Adding a line to class Foo like:

    operator int() { return i; }
    

    Means we can now write:

    cout << "Foo h = " << h << endl;
    

    Wherein h is automatically converted to an int.

    Automatic conversions can transpire between quite a number of built in types. Between double/long-double/float and int/short/long/etc and signed/unsigned and etc. (Incidentally, that’s a really good way to screw yourself up, by invoking the wrong overloaded function by mistake. Converting -1 to unsigned makes for big numbers… Accidentally doing unsigned math where you mean to do signed math is another easy gotcha!)

    Pointers can be quietly converted to (void*). Consider:

    void voidFunction (void * v) { cout << "v= " << v << endl; }
    
    int main() { Foo z(2); voidFunction(&z); }
    

    Of course, the obvious case that everyone harps on is polymorphism, wherein we pass a derived class, and it’s received as a base class.

    There’s another case wherein we pass data, and a new temporary object is created from that data for the invoked function/method.

    There are variable-argument lists, that whole ellipsis thing (printf(format,…)). (E.g. #include <stdarg.h>. va_start(), va_arg(), va_end().) Implicitly overloaded, but probably not what he was thinking about…

    There are macros, both regular #define FOO(X) and variable-argument-list macros… Again, clearly overloaded. Again, probably not what he was thinking of…

    There’s templating, though that would seem to fall into the realm of explicit overloading…

    Bottom line: Only your teacher knows what the hell he wants… Good luck!

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

Sidebar

Related Questions

Full disclosure : This is for a homework assignment. This is driving me nuts.
Full disclaimer: this is not really a homework, but I tagged it as such
Full disclosure, this is part of a homework assignment (though a small snippet, the
Full disclosure: this is for an assignment, so please don't post actual code solutions!
First, in order to provide full disclosure, I want to point out that this
First off, full disclosure: This is going towards a uni assignment, so I don't
How would you define testing? In the interest of full disclosure, I'm posting this
The full specializations of std::atomic for integral types provide arithmetic compound assignment operators such
[Full disclosure: Cross-post between here and ServerFault, because I believe the audiences (server admins
Full Disclosure: There's a similar question here . Is there any way I can

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.