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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:21:12+00:00 2026-06-11T10:21:12+00:00

I have been writing some code for a lib and experimented with a default

  • 0

I have been writing some code for a lib and experimented with a default Win32 console application to get everything running. Since I have completed all classes I wanted to extract everything into a DLL and therefore I started the adaptation with the usual macro:

#ifdef MYLIB_EXPORTS
    #define DllExport __declspec(dllexport)
#else
    #define DllExport __declspec(dllimport)
#endif

I am using one interface in my code which is defined like this:

__interface DllExport ISerializable {
    void Serialize(/* ... */);
    /* some other methods */
};

And this has worked while gaving this code in my exe. In the DLL I get an error during compilation which states

error C2039: '=' : is not a member of 'MyLib::ISerializable'
error C2664: 'MyLib::DerivedClass::operator =' : cannot convert parameter 1 from 'const MyLib::ISerializable' to 'const MyLib::DerivedClass &'

for every class which inherits ISerializable to implement the required methods. (I am using std::shared_ptr<ISerializable> a few times to have abstraction in my code.) However when I change __interface to class and make all methods pure virtual I do not get this error and compilation succeeds.

Why do I get this error? Why does my class/interface in my DLL need the assignment operator? Is there any workaround?

(Using Visual Studio 2012 RTM on Windows 8 RTM with C++11.)


Here is one segment where this error occurs (error point always to the last } of the class):

class DllExport Tile final : public ISerializable {
public:
    __declspec(property(get=GetIsPassable, put=SetIsPassable))
    bool IsPassable;
    __declspec(property(get=GetTileId, put=SetTileId))
    uint16_t TileId;

    bool& GetIsPassable() { return this->_IsPassable; }
    void SetIsPassable(bool val) { this->_IsPassable = val; }
    uint16_t& GetTileId() { return this->_TileId; }
    void SetTileId(uint16_t val) { this->_TileId = val; }

    bool _IsPassable;
    uint16_t _TileId;

    void Serialize(OutputFileStream& ofs);
    size_t TellSize();
    size_t Unserialize(InputFileStream& ifs, size_t metadata = 0);
};

This error also occurs in a class where I have a property like in the Tile class where I use a std::shared_ptr<ISerializable>.

  • 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-11T10:21:14+00:00Added an answer on June 11, 2026 at 10:21 am

    I guess interfaces don’t have compiler-generated copy constructors or assignment operators.

    One possible solution is to explicitly implement DerivedClass::operator=. That’s because the compiler-generated version will try to call ISerializable::operator=, which doesn’t exist. Same thing for copy constructors.

    Another solution is to make all your classes COM classes 🙂


    Example

    Using your Tile class:

    class DllExport Tile final : public ISerializable { 
    public: 
        Tile(const Tile& tile) :
            _IsPassable(tile._IsPassable), _TileId(tile._TileId)
        {
        }
    
        /* New Code START */
        Tile& operator=(const Tile& tile)
        {
            _IsPassable = tile._IsPassable;
            _TileId = tile._TileId;
            return *this;
        }
        /* New Code END */
    
        __declspec(property(get=GetIsPassable, put=SetIsPassable)) 
        bool IsPassable; 
        __declspec(property(get=GetTileId, put=SetTileId)) 
        uint16_t TileId; 
    
        bool& GetIsPassable() { return this->_IsPassable; } 
        void SetIsPassable(bool val) { this->_IsPassable = val; } 
        uint16_t& GetTileId() { return this->_TileId; } 
        void SetTileId(uint16_t val) { this->_TileId = val; } 
    
        bool _IsPassable; 
        uint16_t _TileId; 
    
        void Serialize(OutputFileStream& ofs); 
        size_t TellSize(); 
        size_t Unserialize(InputFileStream& ifs, size_t metadata = 0); 
    }; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing some basic code for an application I am designing. I
I have been writing some code to create a byte array I will be
I have been messing around with writing some stored procedures in .NET code with
I have been writing some code that creates a generic blog. Its features are
I have been writing some C# code for a training exercise, in which I
I have been writing some code with basically this structure namespace util { void
All, I have been writing some code to attempt to extract a collection of
I have been writing some code that detects add and removal of USB devices,
I have been writing some rspec tests, and right now I want to verify
I am trying to learn more about the DOM and have been writing some

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.