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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:17:05+00:00 2026-06-05T22:17:05+00:00

To be honest, I do not really know how to name that problem. I’ll

  • 0

To be honest, I do not really know how to name that problem. I’ll just show the code that is not working:

template<int SIZE>
struct bar{

};

template<int SIZE>
struct foo{
    template<int X>
    void f(bar<X> b);
};

template<int SIZE, int X>
void foo<SIZE>::f(bar<X> b){

}


int main(){
    foo<1> f;
    bar<2> b;
}

I’d like to separate definition from implementation to avoid cyclic dependency issues. Separation is done in header files only, I don’t want to put template code into cpp files. Using pointers is no option in that case. Refactoring has been considered but is not a real option, either.

Implementing foo::f without a parameter that has template parameters itself is working fine. I do not really get the problem with that parameter, though.

Code should work using gcc 4.7 and (even more important) Visual Studio 2010. C++11 is ok as long as supported by the platforms mentioned.

Solutions, workarounds as well as theoretical explanations why I’m doing something completly wrong will be highly appreciated. TIA.

  • 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-05T22:17:07+00:00Added an answer on June 5, 2026 at 10:17 pm
    template<int SIZE, int X>    //problem : what is what here?
    void foo<SIZE>::f(bar<X> b){
    
    }
    

    It is wrong syntax.

    The correct syntax is to use template twice as:

    template<int SIZE>   //for the class template
    template<int X>      //for the member function template
    void foo<SIZE>::f(bar<X> b){
    
    }
    

    Note that the order matters here.

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

Sidebar

Related Questions

to be honest, I don't really know what the small green men in my
So I have an app that if I'm honest doesn't really need transactional integrity
I know there are already some questions about this, but not that specific. I
(This looks like a long question, but it's not really, honest!) I am trying
I'll be honest, I've patched together code from a couple of sources without really
I'm working on my first Android app and to be honest I'm not sure
I am just going to be honest and say that I hate building web
This might be really obvious, but I'll be honest, I'm not any kind of
To be honest I'm not quite sure if I understand the task myself :)
I'll be honest, I am not sure of the terms I used in the

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.