Can I allocate unique_ptr outside the function?
Is this correct? So can I allocate the dynamic var outside the function?
Assign unique_ptr of derived class to a base class
Why this code doesn’t compile?
// Type your code here, or load an example.
How can I get uique_ptr data from file?
class A { string name; size_t num; unique_ptr<char[]> p; public: void write(ostream& os) { os.write((char*)this, sizeof(a)); os.write((char*))p.get(), num); } There is a file made by write(). I open the file with ios::binary, and i try to get a lot of A with read(). void read(istream& is) { is.read(reinterpret_cast<char*>(this), sizeof(A)); p = make_unique<char>(num); is.read(p.get(), num) } […]