1 #include <iostream> 2 /* #include <string> 3 #include <sstream> */ 4 class C 5 { 6 int x = 0; 7 public: 8 //1. 9 C(int x):x{x}{ 10 std::cout<<"C(" + std::to_string(x) + ")"<<" "; 11 } 12 13 //2. 14 C(double d):C(static_cast<int>(d)){ 15 std::string s = std::to_string(d); 16 std::cout<< "C(" + s.erase(s.find_last_not_of('0')+1) + ")" <<std::endl; 17 /* std::ostringstream oss; 18 oss<<d; 19 std::cout<< "C(" + oss.str() + ")" <<std::endl; */ 20 } 21 22 //3. 23 C():C(3.8){ 24 std::cout<<"C()"<<std::endl; 25 } 26 }; 27 int main() 28 { 29 C c3; 30 C c2{2.2}; 31 C c1{1}; 32 return 0; 33 }