Код: Выделить всё
#include
#include
class Simple
{
public:
Simple(const std::string& data)
: data_(data)
{
}
auto operator(const Simple&) const = default;
private:
const std::string& data_;
};
int main()
{
std::string str1 = "one";
Simple s1(str1);
std::string str2 = "two";
Simple s2(str2);
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79183960/why-are-explicitly-defaulted-comparison-operators-deleted-when-the-class-contain[/url]
Мобильная версия