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

  • Home
  • SEARCH
  • 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 8077331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:27:03+00:00 2026-06-05T15:27:03+00:00

So i have been creating this framework thing that basically puts together source code

  • 0

So i have been creating this “framework” thing that basically puts together source code (for shaders). I thought i was pretty clever when i came up with the idea of making a statement class and overloading all of its operators (changing their meaning completely) to form other statements in a natural way. It looks like this:

class Statement {

public:
    Statement operator=(const Statement &other) const;
    Statement operator+(const Statement &other) const;
    ...

}

However, when i thought i was done, it turned out that the operator= completely disregarded the return value and instead just always returned the object before the ‘=’. Do i understand it correctly that there is no way to accomplish this?

EDIT: Ok, sorry, the example i provided compiles (i had the operator overloaded in A too which didn’t work).

EDIT 2: The operator= is actually const on purpose: Its intended meaning is to create a new assignment statement object.

Example:

Block b; // Represents a sequence of commands.
Statement var1, var2; // Represent some variables.
...
b.append(var1 = var2);

Expected: b includes the command var1 = var2;

Observed: b includes var1;

Resolved: The problem was because i was using a derived class instead of Statement which used its default operator=. Thanks everyone.

  • 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-05T15:27:04+00:00Added an answer on June 5, 2026 at 3:27 pm

    Unless you declare one, a class always has an implicitly-declared copy-assignment operator with the signature:

    Statement& operator=(const Statement&)
    

    Note it is not const, so is preferred when assigning to a non-const object, because your assignment operator is const. [Edit: my mistake, the const assignment operator suppresses the implicit one, so the unconventional const-qualified assignment operator should be used.]

    (how do you expect to assign to I.e. modify, a const object?)

    (N.B. to be more accurate, the implicitly-declared assignment operator could have the signature Statement& operator=(Signature&) if a sub-object declares an assignment operator with that signature, but that’s not the case in your example.)

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

Sidebar

Related Questions

I have been reading that creating dependencies by using static classes/singletons in code, is
I have been creating a peer to peer connection for a new game, that
I have been asked to look into FileMaker for creating a pretty simple database
I'm in the process of creating my own framework and have been looking at
In the past years I have been working on different projects that required creating
I have been creating an image gallery with jQuery, all is done. The images
I have been creating an app for Android SDK 8 and it works fine.
So far I have been creating Web Portal but recently I had a request
I have been successful with creating a Telerik grid to display a list of
I have been tasked with creating a site wide search feature. The search needs

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.