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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:31:05+00:00 2026-06-11T00:31:05+00:00

I am busy doing an assignment for a Comp Sci module in C++ and

  • 0

I am busy doing an assignment for a Comp Sci module in C++ and I am just a bit confused by one of the questions. It asks to give 3 implementations of an overloaded increment operator:

  1. Using the member function Adjust() which was coded in a previous question.
  2. Implementing the overloaded operator as a friend function.
  3. Implementing the overloaded operator as a member function.

Now I understand the concept of overloading the operators I think, that’s okay. But I’m actually not too sure about the first one, using the existing member function Adjust(). Because surely if I’m overloading and just calling another function it will either be a friend or a member function calling another member function, if you know what I mean. Anyway, any help would be greatly appreciated. Below is my code for number 2 and 3 just for reference.

//Friend Function
friend Chequebook operator ++(const Chequebook &c); //Declaration in class.
Chequebook operator++(const Chequebook &c) //Function
{
    return Chequebook(c.Balance+100);
}

//Member Function
Chequebook operator++(); //Declaration in class.
Chequebook Chequebook::operator++() //Function.
{
    return Chequebook(Balance+100);
}

Sorry for the errors in the code. This is supposed to be a pre-increment operator overload.

  • 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-11T00:31:07+00:00Added an answer on June 11, 2026 at 12:31 am

    You probably misunderstand what increment operator does or you did not post full text of homework.

    It modifies the object. It can be member and nonmember. It can be prefix and postfix. Here are the examples of how prefix (++x) increment is usually implemented:

    class X 
    {
      int i;
    public:
    
      // member prefix ++x
      X& operator++() { ++i; return *this;}
    };
    
    class Y 
    { 
      int i;
    public:
      void adjust() {++i;}
    };
    
    // non-member prefix ++y
    Y& operator++(Y& y) { y.adjust(); return y;}
    
    class Z 
    { 
      int i;
    public:
      // friend prefix ++z
      friend Z& operator++(Z& z) { z.i++; return z;}
    };
    

    The postfix increment (x++) is different, should have additional int parameter.

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

Sidebar

Related Questions

I am busy preparing for exams, just doing some old exam papers. The question
I am busy doing an UPDATE/INSERT request, but here is the crux: table PLAYERS
I am busy doing some research into using REST services with mobile applications and
I have a bachelor in computer science. And have been busy doing security research
I'm currently writing a simple webserver in C for a course I'm doing. One
I am busy with a login system for my project. Just for an extra
Busy playing with django, but one thing seems to be tripping me up is
I'm busy getting to know a tiny bit of C/C++, and interop with C#.
i have winform (c#) with multi-tabs, the current focused tab is busy doing lengthy
busy for several hours now, to find out what i am doing wrong. In

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.