Test.h
#include <memory>
#include <string>
using namespace std;
class A
{
public:
A GetTitle();
private:
unique_ptr<A> title;
};
Test.cpp
#include <memory>
#include "Test.h"
A A::GetTitle()
{
return *this->title.get();
} // Error here
int main()
{
}
I'm getting the following error:
C2280: 'std::unique_ptr>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' : attempting to reference a deleted function
what am i doing wrong here? Is it down to the ownership of this->keyServer
? How do i pass just the value back so that i am not at all allowing users of the function to modify the value inside the class without using setter?
unique_ptr
here? Is it really a resource that only one copy of should exist at a time? – Donnie