All of
std::string s(1, c); std::cout << s << std::endl;
and
std::cout << std::string(1, c) << std::endl;
and
std::string s; s.push_back(c); std::cout << s << std::endl;
worked for me.
More Related Contents:
- Why it is so ? And It is without you explicitly do casting [duplicate]
- When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?
- Implicit type conversion rules in C++ operators
- When to use reinterpret_cast?
- What does casting to `void` really do? [duplicate]
- dynamic_cast and static_cast in C++
- How is a variable at the same address producing 2 different values? [duplicate]
- What is the difference between (type)value and type(value)?
- What exactly is a type cast in C/C++?
- Should I worry about the alignment during pointer casting?
- Cast pointer to member function to normal pointer
- Reinterpret_cast vs. C-style cast
- Implicit conversion from char** to const char**
- Weird Behaviour with const_cast [duplicate]
- Can a cast operator be explicit?
- casting via void* instead of using reinterpret_cast [duplicate]
- Difference in behavior while using dynamic_cast with reference and pointers
- Casting int to bool in C/C++
- Passing shared_ptr as shared_ptr
- What is the difference between C-like casting and functional casting? [duplicate]
- What exactly is or was the purpose of C++ function-style casts?
- Why cast a pointer to a float into a pointer to a long, then dereference?
- Why doesn’t this reinterpret_cast compile?
- Performance hit from C++ style casts?
- C++: Why is const_cast evil?
- Purpose of a “.f” appended to a number?
- Should I use a C++ reinterpret_cast over a C-style cast?
- Why Doesn’t reinterpret_cast Force copy_n for Casts between Same-Sized Types?
- How to cast simple pointer to a multidimensional-array of fixed size?
- How can I extend a lexical cast to support enumerated types?