Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

operator with default definition fails to compile

$
0
0

When overriding operator `=` with default fails to compile.

Is this a bug or am I missing something?

Error Message

icpc -std=c++17 sample.cpp
ld: /tmp/icpczIU0ix.o:(.rodata._ZTV6Entity[_ZTV6Entity]+0x10): undefined reference to `Entity::operator=(Entity const&)'

Source code

#include <iostream>
class Entity {
    public:
        Entity() = default;
        virtual Entity & operator = ( Entity const & )=default;
    public:
        int index;
};

Entity e1 = Entity();

int main() {
    std::cout << e1.index;
    return(0);
}

Intel c++ compiler version

icpc (ICC) 19.0.5.281 20190815

TCE Open Date: 

Sunday, November 17, 2019 - 20:30

Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>