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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:40:29+00:00 2026-05-17T01:40:29+00:00

why if we have pure virtual assignment operator in a base class, then we

  • 0

why if we have pure virtual assignment operator in a base class, then we implement that operator on the derived class, it give linker error on the base class?

currently I only have the following explanation on http://support.microsoft.com/kb/130486 , it said that the behavior is by design since normal inheritance rules does not apply.

it is not clear for me, why is it generate linker error by design? can someone give me more clear explanation about this?

edit: added my simplified code of which the error occured:

class __declspec(dllexport) BaseClass {
public:
    int memberA;
    virtual BaseClass& operator=(const BaseClass& rhs) = 0;
};

class __declspec(dllexport) DerivedClass : public BaseClass {
public:
    int memberB;
    DerivedClass():memberB(0) {}
    virtual BaseClass& operator=(const BaseClass& rhs) {
        this->memberA = rhs.memberA;
        this->memberB = 1;
        return *this;
    }
};

int main(void)
{
    DerivedClass d1;
    DerivedClass d2;

    BaseClass* bd1 = &d1;
    BaseClass* bd2 = &d2;

    *bd1 = *bd2;
}

the code will compile with no errors without __declspec(dllexport) and/or without pure virtual operator= declaration on base class.

without __declspec(dllexport) after assignment of *bd1 = *bd2;, d1::memberB is 1, but with __declspec(dllexport) d1::memberB is left unchanged

with __declspec(dllexport), and without pure virtual declaration, after assignment of *bd1 = *bd2;, d1::memberB is left unchanged

  • 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-17T01:40:30+00:00Added an answer on May 17, 2026 at 1:40 am

    From section 12.8 of the standard:

    13 The implicitly-defined copy assignment operator for class X performs memberwise assignment of its subobjects. The
    direct base classes of X are assigned first, in the order of their declaration in the base-specifier-list
    , and then the immediate
    non-static data members of X are assigned, in the order in which they were declared in the class definition. Each subobject
    is assigned in the manner appropriate to its type:

    — if the subobject is of class type, the copy assignment operator for the class is used (as if by explicit qualification;
    that is, ignoring any possible virtual overriding functions in more derived classes);

    The subclass is using the implicitly-defined copy assignment operator, and there is no definition of the base class’s copy assignment operator, but it is declared, so you get a link error instead of a compilation error.

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

Sidebar

Related Questions

Basically, I have a pure virtual class Base, and a concrete class Derived which
If I have a base class with a pure-virtual function, and a derived class
I have a base class MyBase that contains a pure virtual function: void PrintStartMessage()
Lets say I have an abstract base class with a pure virtual that returns
Suppose I have a pure virtual method in the base interface that returns to
I have a function X() declared as PURE VIRTUAL in base class: class Base
The pure virtual destructor in base class should have a definition. Otherwise compiler will
I have a base class class Animal with pure virtual functions, and a set
I have a base resource that contains pure virtual functions like load and unload.
I have an abstract class defining a pure virtual method in c++: class Base

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.