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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:28:13+00:00 2026-05-27T22:28:13+00:00

Class declaration: class unaryOperators { public: int i; unaryOperators (int tempI = 0) {

  • 0

Class declaration:

class unaryOperators 
{
    public:
        int i;

        unaryOperators (int tempI = 0)
        {
            i = tempI;
        }

        unaryOperators operator++ (int);
        unaryOperators operator++ ();
};

Does this global definition correspond to postfix or prefix version of the overloaded operator++? Why?

unaryOperators operator++ (unaryOperators &one)
{   
    return one; 
}
  • 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-27T22:28:14+00:00Added an answer on May 27, 2026 at 10:28 pm
    unaryOperators& operator++ (unaryOperators &one)
                  ^^
    

    is the non-member prefix unary increment operator.

    The non-member postfix unary increment operator takes an additional int as an policy enforcing parameter.

    unaryOperators operator++ (unaryOperators &one, int)
    

    Reference:

    C++03 Standard 13.5.7 Increment and decrement [over.inc]

    The user-defined function called operator++ implements the prefix and postfix ++ operator. If this function is a member function with no parameters, or a non-member function with one parameter of class or enumeration type, it defines the prefix increment operator ++ for objects of that type. If the function is a member function with one parameter (which shall be of type int) or a non-member function with two parameters (the second of which shall be of type int), it defines the postfix increment operator ++ for objects of that type. When the postfix increment is called as a result of using the ++ operator, the int argument will have value zero.125)

    [Example:
    class X {
       public:
          X& operator++(); // prefix ++a
          X operator++(int); // postfix a++
    };
    class Y { };
    Y& operator++(Y&); // prefix ++b
    Y operator++(Y&, int); // postfix b++
    
    void f(X a, Y b) {
    ++a; // a.operator++();
    a++; // a.operator++(0);
    ++b; // operator++(b);
    b++; // operator++(b, 0);
    a.operator++(); // explicit call: like ++a;
    a.operator++(0); // explicit call: like a++;
    operator++(b); //explicit call: like ++b;
    operator++(b, 0); // explicit call: like b++;
    }
    —end example]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a declaration like this: class A { public: void Foo() const; }; What
Possible Duplicate: What do parentheses surrounding a JavaScript object/function/class declaration mean? What does this
In C# how does a declaration differ from a definition, i.e.: A class declaration
Say you have a class declaration, e.g.: class MyClass { int myInt=7; int myOtherInt;
Here's what I want the resulting class declaration to look like: public sealed partial
What does ::Base part mean in Person < ActiveRecord::Base class declaration? I'm new to
I'm having some problems with this piece of code. I've included a class declaration
I have a class with the following declaration of the fields: public class Game
Regarding class public class declaration, please look at these two pieces of code: public
Here is my class declaration: public class XmlMembershipProvider : MembershipProvider {....} and my web.config

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.