C++ template specialization inside a class error
Clash 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!
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.
Can you show how you wrote it outside the class scope?
– NathanOliver
3 mins ago