C
C
CPPJunior2015-04-20 15:21:17
C++ / C#
CPPJunior, 2015-04-20 15:21:17

How to correctly declare a friend function in a class?

Hello. Errors appeared after switching to Visual Studio 2013. I have the following code:

class Data
{
public:
   typedef boost::shared_ptr<Data> s_ptr;
   friend s_ptr boost::make_shared<Data>(int const & d); // c2063, c4346, c2998
   static s_ptr create(int id) { return boost::make_shared<Data>(id); }
private:
   explicit Data(int id): id_(id) {}
};

An error occurs on the declaration of a friend function:
error C2063: 'boost::make_shared' : not a function
warning C4346: 'boost::make_shared' : dependent name is not a type 
prefix with 'typename' to indicate a type
error C2998: 'make_shared' : cannot be a template definition

Tried replacing with std::shared_ptr , same error. Please tell me how to fix. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maaGames, 2015-04-20
@maaGames

include is missing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question