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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:04:51+00:00 2026-05-30T01:04:51+00:00

I have created an overloaded operator for ++ in my .hpp file and then

  • 0

I have created an overloaded operator for ++ in my .hpp file and then a function which calls it also in the .hpp file. The .cpp file then calls the function but when the function hit the ++ code it doesnt eneter the overloaded operator but instead used the default operation operator for ++. Why isnt it using my overloaded operator?

Here is the operators for ++:

iterator& operator ++ () {  // pre-increment
        std::list<value_type>::iterator i = listOfValues.begin();
        advance(i,1);
        return &*i;
    }

    Square_List operator ++ (int) { // post-increment
        std::list<value_type>::iterator i = listOfValues.begin();
        advance(i,1);
        return &*i;
    }

And here is the function using it:

template <typename A_>
void testerIncrement(A_ toInc)
{

    toInc = listOfValues.begin();
    cout << "\n" << *toInc;
    ++toInc;
    cout << "\n" << *toInc;
    ++toInc;
}

And lastly the call for the function in the .cpp file

ca.testerIncrement(ca.listOfValues.begin());
  • 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-30T01:04:53+00:00Added an answer on May 30, 2026 at 1:04 am

    You overload the prefix increment operator ++ with either a nonmember function operator that has one argument of class type or a reference to class type, or with a member function operator that has no arguments.

    It seems you are using non member operators. So your syntax should be
    void operator++(iterator &); //prefix
    and void operator++(Square_List, int); //postfix.

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

Sidebar

Related Questions

I have overloaded << operator such that it write to file and also on
I have created a class named Times and I have to construct 4 overloaded
I have created a file with XmlDocument xmldoc = new XmlDocument(); Can I make
i have created a simple public ref class in the vc++ project, which is
I have the following Groovy code snippet that is attempting to use operator overloading
I've been having some problems trying to implement an overloaded << operator function that
I have created new objects with Dojo.declare. How to overload operator == for objects
I've created a small utility function for string conversion so that I don't have
We have large (100,000+ elements) ordered vectors of structs (operator < overloaded to provide
Possible Duplicate: Solution for overloaded operator constraint in .NET generics I have a problem

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.