C++ template specialization inside a class error

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



C++ template specialization inside a class error



I am pretty new to c++ and I have the following error:


error: explicit specialization of 'get' in class scope
template <> string get<string>() {



This is the code


class ReadFile
public:
template <typename T> T get()
//...


template <> string get<string>()
//...

private:
//...
;



By reading the error code, I wrote the template function outside the class scope and I got this error:


duplicate symbol __ZN8ReadFile3getINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEET_v in:



So if that is not working how should it be written?
Thank you for any help!





Can you show how you wrote it outside the class scope?
– NathanOliver
3 mins ago





Even if outside of class scope, it should be still inside of the header file.
– HolyBlackCat
3 mins ago





related :stackoverflow.com/questions/26305368/…
– Rakete1111
2 mins ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard