我正在尝试将ac#项目转换为c ++.我正在尝试以下方法:
class IDocInterface
{
public:
// implemented in CSpecificDoc
virtual bool CreateDoc() = 0;
// implemented in COperations
virtual void AddOperation() = 0;
// implemented in CDoc
virtual void Save() = 0;
};
class COperations
{
public:
void AddOperation() {}; // implementation for CDoc and derivates
};
class CDoc : public IDocInterface, public COperations
{
public:
void Save() {}; // implemented here
};
class CSpecificDoc : public CDoc
{
public:
bool CreateDoc() {}; // implemented here
};
Run Code Online (Sandbox Code Playgroud)
当我尝试做的时候:
IDoc …Run Code Online (Sandbox Code Playgroud) I came across an elegant line of reading a binary file into a vector like this (that works):
std::ifstream ifs("myfile.bin", std::ios::binary);
std::vector<char> buffer(std::istreambuf_iterator<char>(ifs), {});
Run Code Online (Sandbox Code Playgroud)
Instead since I want my vector to be a shared pointer I write:
std::ifstream ifs("myfile.bin", std::ios::binary);
auto sp = std::make_shared<std::vector<char>>(std::istreambuf_iterator<char>(ifs), {});
Run Code Online (Sandbox Code Playgroud)
I.e just pass the vector constructor arguments to make_shared (as I usually do to create any shared pointer of any objects). But I get: error: no matching function for call to 'make_shared'?
Detailed output:
/usr/include/c++/11.1.0/bits/shared_ptr.h|873 …