Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:14:20+00:00 2026-06-13T07:14:20+00:00

I can define a specialized function in a cpp like so… // header template<typename

  • 0

I can define a specialized function in a cpp like so…

// header

template<typename T>
void func(T){}

template<>
void func<int>(int);

// cpp

template<>
void func<int>(int)
{}

How can I define a method in a specialized class in a cpp? Like so (which doesn’t work, I get error C2910: 'A<int>::func' : cannot be explicitly specialized)…

// header

template<typename T>
struct A
{
    static void func(T){}
};

template<>
struct A<int>
{
    static void func(int);
};

// cpp

template<>
void A<int>::func(int)
{}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:14:21+00:00Added an answer on June 13, 2026 at 7:14 am

    Use following syntax in your .cpp file:

    void A<int>::func(int)
    {
    }
    

    This is Visual C++ kinda feature.

    See MSDN C2910 error description for details:

    This error will also be generated as a result of compiler conformance work that was done in Visual Studio .NET 2003:. For code will be valid in the Visual Studio .NET 2003 and Visual Studio .NET versions of Visual C++, remove template <>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to define a constructor for an explicitly specialized class template outside
I can define default value in domain by this way : class ProcessingPriority {
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
The usual definition for a specialization of a template function is something like this:
Is it possible to call a function defined in a non-specialised template class from
I want to define template variables without a class, but MSVC++ does not accept
For my program i need to define a Solver class which can either solve
How do you receive serialization events? You can define void writeObject(ObjectOutputStream out) { //
Is this valid C++? template<class category> class any_iterator : public any_iterator<void> { public: typedef
How can I define a [OperationContract] [WebGet] method to return XML that is stored

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.