Im trying to call default copy constructor with uniform initialization, but it's not working.
For example:
#include <string>
struct Work {
std::string author;
std::string name;
int year;
};
int main() {
Work s9 {"Beethoven", "Symphony No. 9 in D minor, Op. 125; Choral", 1824}; // memberwise initialization
Work currently_playing {s9}; // copy initialization
return 0;
}
Im compiling it as: g++ -std=c++11 -c Ex1.cpp
And compiler gives error:
Ex1.cpp: In function ‘int main()’:
Ex1.cpp:11:28: error: could not convert ‘s9’ from ‘Work’ to ‘std::string {aka std::basic_string<char>}’
Work currently_playing {s9}; // copy initialization
^
Doesn't uniform initialization work to copy initialize object?