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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:43:08+00:00 2026-05-27T19:43:08+00:00

Suppose I have a class that doesn’t support memberwise copying so I don’t want

  • 0

Suppose I have a class that doesn’t support memberwise copying so I don’t want to preserve compiler-implemented copy-constructor and assignment operator. I also don’t want to implement those because either

  1. doing so takes extra effort and I don’t need those operations in my class or
  2. those operations won’t make sense in my class

so I want to prohibit them. To do so I’ll declare them private and provide no implementation:

class NonCopyable {
private:
   NonCopyable( const NonCopyable& ); //not implemented anywhere
   void operator=( const NonCopyable& ); //not implemented anywhere
};

Now I can select any return type for operator=() member function. Will it matter which return type I select?

  • 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-27T19:43:08+00:00Added an answer on May 27, 2026 at 7:43 pm

    It matters a tiny, tiny bit:

    • void ensures a small percentage of accidental/misguided calls (a = b = c / f(d = e)) from within the class’s implementation produce compile time errors rather than link time errors, which may save compile time and be more understandable (minimally relevant for large classes touched by many developers, some with limited prior familiarity).

    • void would ring an alarm bell for me (and hopefully most developers), wondering whether you:

      • wanted to remove the default-generated operator=
      • were just lazy about the extra typing, or
      • were unfamiliar/uncaring re the generally expected semantics of operator=.

    With the open question in mind, other programmer are less likely to come along and think you just didn’t get around to providing the implementation and add it casually (you may feel comments are adequate).

    • returning a reference to type may make the overall function signature more instantaneously recognisable, or visually searching past a complicated type to find operator= could have the opposite effect – all in the eye (and mind) of the beholder….
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a class that I want to make sure my compiler (GCC
Suppose I have a Python class that I want to add an extra property
Suppose I have a class that processes some data: class SomeClass { public: void
Suppose I have a class Customer that is mapped to the database and everything
Suppose I have a Base class and a Child class that inherits from Base
Suppose that we have a class called class1. The class1 has a method called
Suppose that I have a Java class with a static method, like so: class
Suppose that I have an integer variable in a class, and this variable may
Suppose class B extends class A . I have a List<A> that I happen
Suppose I have a MyException class that subclasses Exception. I'm using this class to

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.