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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:35:42+00:00 2026-05-26T23:35:42+00:00

Scott Meyers in his book Effective C++ says, To disallow functionality automatically provided by

  • 0

Scott Meyers in his book “Effective C++” says,

To disallow functionality automatically provided by compilers, declare
the corresponding member functions private and give no
implementations.Then if somebody inadvertently calls one, they will
get an error at link-time.

I tried to write a sample program for achieving what Scott was trying to explain. I could achieve the same even when the member function was declared public and given no implementation. The link-error occurred in my case also when i tried to initialize an object from another object. So i do not understand why Scott is emphasizing on the need of member function to be declared private?

My sample program is written below:

#include <iostream>

using namespace std;

class Unique
{
   private:
      int num;

   public:
      Unique(int x)
      {
         num  = x;
      }
      Unique(const Unique &obj);

      Unique& operator =(const Unique &obj);

      void disp(void)
      {
         cout << "num = " << num << "\n";
      }
};

int main()
{
   Unique ob1(3);
   Unique ob2(ob1);

   ob1.disp();
   ob2.disp();

   return 0;
}

I get the following link-error:

/tmp/ccXfqSqE.o(.text+0x135): In function main': : undefined
reference to
Unique::Unique(Unique const&)’ collect2: ld returned 1
exit status

  • 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-26T23:35:43+00:00Added an answer on May 26, 2026 at 11:35 pm

    Compiler errors are clearer and happen earlier (this is more pronounced in big projects ccompiled from a lot of source files) than link errors. They are also easier to read most of the time. Declaring members private provokes compile errors and is therefore preferred over leaving members undefined to disallow them.

    As Baptiste notes, in C++11 there is the even better delete keyword available for disallowing compiler-generated members:

    class A
    {
         A(constA&) = delete; // copy construction is not allowed
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to Scott Meyers, in his Effective STL book - item 46. He claimed
recently I've been reading through Scott Meyers's excellent Effective C++ book. In one of
I am reading Scott Meyers Effective C++ book. It was mentioned that there are
Good morning , In Scott Meyers book Effective STL, Mr Meyers explains how the
Both Marshall Clines' C++ FAQ Lite and Scott Meyers' Effective C++ suggest using functions
Good day! In his Effective STL Scott Meyers wrote A third is to use
I am reading at the time the "Effective C++" written by Scott Meyers and
In effective STL by Scott Meyers (page 195) there is the following line: The
Scott Meyers in Effective C++ points at the ability to do e.g. matrix operations
From Effective C++ by Scott Meyers: template<typename T, std::size_t n> class SquareMatrix: private SquareMatrixBase<T>

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.