Igor
Igor

Reputation: 6285

Error for the nullptr in smart ponter initializatin

ALL,

Using MSVC 2017.

When I had the code like this:

class Foo
{
private:
    LibraryObject *m_library;
};

my code compiled fine.

But when I tried to do it like this:

class Foo
{
private:
    std::shared_ptr<LibraryObject> m_library( nullptr );
};

ref. https://learn.microsoft.com/en-us/cpp/cpp/how-to-create-and-use-shared-ptr-instances?view=msvc-170 Example 1 at the end f the code, I started getting the error:

error C2059: syntax error: 'nullptr'

Cold someone please explain why am I getting the error?

TIA!!!

Upvotes: 0

Views: 69

Answers (0)

Related Questions