I am quite new to this level of coding. Here is the offending code
#include <iostream>
class var {
public:
var(const var& v, char name = ' ') : name_(name) {}
explicit var(double v, char name = ' ') : name_(name) {}
char name() { return name_; }
private:
char name_;
};
int main() {
var x(10, 'x');
var y = x;
std::cout << x.name() << std::endl; // 'x'
std::cout << y.name() << std::endl; // ' '
return 0;
}
when I inspect the objects being generated the value of x is 'x', and the value of y is ' '. This should also be 'x'