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 7685495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:15:50+00:00 2026-05-31T19:15:50+00:00

Given: template<class T> struct test { void foo(int b); void testFunc( int a )

  • 0

Given:

template<class T>
struct test {

    void foo(int b);

    void testFunc( int a )
    {
    }

};

void test::foo(int b)
{

}


template<>
void test<float>::testFunc( int a )
{

}

void someFunction()
{
}

We know that “test::foo” has a declaration in the test class, and a definition outside the class definition.
We also know that “someFunction” has a declaration which is also its definition.
In like manner “test::testFunc” (non-specialized), has a declaration which is also its definition.
Is the specialization function “test<float>::testFunc” said to be declared with the declaration of “testFunc” inside of class “test” and defined separately, or is its declaration also the definition?

  • 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-05-31T19:15:51+00:00Added an answer on May 31, 2026 at 7:15 pm

    The explicit specialization in your example is a declaration that is also a definition. You could also declare it separately:

    template<>
    void test<float>::testFunc( int a );
    

    and if the function was used, the linker would expect it to be defined somewhere.

    The declaration inside the class is the declaration and definition of the member function template.

    BTW, foo should be defined like this:

    template <class T>
    void test<T>::foo(int b)
    {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a C++ template class (or function) definition: template<typename T> struct Foo { T
Given: struct Field { template<class T> T Value() const { // ??? } template<class
I have a class A: template <typename T, int I> struct A {}; and
Given a class with a member template function like this one: template <typename t>
Given the following piece of code: template<typename T> class MyContainer { typedef T value_type;
Using SFINAE, i can detect wether a given class has a certain member function.
I have a simple container : template <class nodeType> list { public: struct node
Given the following base class: struct ValueType { String ToString(String const& format) const; };
I understand that the member names of a base-class template are hidden within the
Trying to get tensor_ref<A>::result visible in tensor_view. template<class A, class Range, class = void>

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.