Template member of template class implementation in header fileAre static class variables possible in Python?Use 'class' or 'typename' for template parameters?Why have header files and .cpp files?Why can templates only be implemented in the header file?When can I use a forward declaration?Where and why do I have to put the “template” and “typename” keywords?Why are C++ inline functions in the header?Is std::unique_ptr<T> required to know the full definition of T?“Undefined reference to” template class constructorImage Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition

Has SHA256 been broken by Treadwell Stanton DuPont?

Is は a particle in こんにちは and こんばんは?

Consonance v. Dissonance

Why don't Wizards use wrist straps to protect against disarming charms?

Read string of any length in C

What 68-pin connector is this on my 2.5" solid state drive?

I was promised a work PC but still awaiting approval 3 months later so using my own laptop - Is it fair to ask employer for laptop insurance?

Why is my fire extinguisher emptied after one use?

What's the benefit of prohibiting the use of techniques/language constructs that have not been taught?

Are there successful ways of getting out of a REVERSE MORTGAGE?

How to publish superseding results without creating enemies

Are there any “Third Order” acronyms used in space exploration?

What is this gigantic dish at Ben Gurion airport?

Make 2019 with single digits

Planar regular languages

Python web-scraper to download table of transistor counts from Wikipedia

How would you control supersoldiers in a late iron-age society?

Parallel resistance in electric circuits

Is there any reason to concentrate on the Thunderous Smite spell after using its effects?

How does a simple logistic regression model achieve a 92% classification accuracy on MNIST?

What does "boys rule, girls drool" mean?

Does a succubus' charm end when it dies?

Make 1998 using the least possible digits 8

New default file type?



Template member of template class implementation in header file


Are static class variables possible in Python?Use 'class' or 'typename' for template parameters?Why have header files and .cpp files?Why can templates only be implemented in the header file?When can I use a forward declaration?Where and why do I have to put the “template” and “typename” keywords?Why are C++ inline functions in the header?Is std::unique_ptr<T> required to know the full definition of T?“Undefined reference to” template class constructorImage Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have a class that looks like this



template<class T>
class Matrix
...
template<class T2> auto dot(Matrix<T2> const& other);



Here is my implementation, under the declaration in the header file :



template<class T, class T2>
auto Matrix<T>::dot(Matrix<T2> const& other)
[impl]



The error I get looks like this :



(C2244) 'Matrix<T>::dot' : unable to match function definition to an existing declaration


Where am I going wrong ?










share|improve this question
























  • You just can't mix two template declarations together, buddy :)

    – L. F.
    Mar 28 at 11:21

















2















I have a class that looks like this



template<class T>
class Matrix
...
template<class T2> auto dot(Matrix<T2> const& other);



Here is my implementation, under the declaration in the header file :



template<class T, class T2>
auto Matrix<T>::dot(Matrix<T2> const& other)
[impl]



The error I get looks like this :



(C2244) 'Matrix<T>::dot' : unable to match function definition to an existing declaration


Where am I going wrong ?










share|improve this question
























  • You just can't mix two template declarations together, buddy :)

    – L. F.
    Mar 28 at 11:21













2












2








2








I have a class that looks like this



template<class T>
class Matrix
...
template<class T2> auto dot(Matrix<T2> const& other);



Here is my implementation, under the declaration in the header file :



template<class T, class T2>
auto Matrix<T>::dot(Matrix<T2> const& other)
[impl]



The error I get looks like this :



(C2244) 'Matrix<T>::dot' : unable to match function definition to an existing declaration


Where am I going wrong ?










share|improve this question














I have a class that looks like this



template<class T>
class Matrix
...
template<class T2> auto dot(Matrix<T2> const& other);



Here is my implementation, under the declaration in the header file :



template<class T, class T2>
auto Matrix<T>::dot(Matrix<T2> const& other)
[impl]



The error I get looks like this :



(C2244) 'Matrix<T>::dot' : unable to match function definition to an existing declaration


Where am I going wrong ?







c++ class templates header-files generic-programming






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 11:14









MagixMagix

1,2792 gold badges12 silver badges33 bronze badges




1,2792 gold badges12 silver badges33 bronze badges















  • You just can't mix two template declarations together, buddy :)

    – L. F.
    Mar 28 at 11:21

















  • You just can't mix two template declarations together, buddy :)

    – L. F.
    Mar 28 at 11:21
















You just can't mix two template declarations together, buddy :)

– L. F.
Mar 28 at 11:21





You just can't mix two template declarations together, buddy :)

– L. F.
Mar 28 at 11:21












1 Answer
1






active

oldest

votes


















3
















The syntax is wrong. You have a function template with template parameter T2 within a class template with template parameter T . It has to be defined like this:



template<class T>
template<class T2>
auto Matrix<T>::dot(Matrix<T2> const& other)







share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55396217%2ftemplate-member-of-template-class-implementation-in-header-file%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3
















    The syntax is wrong. You have a function template with template parameter T2 within a class template with template parameter T . It has to be defined like this:



    template<class T>
    template<class T2>
    auto Matrix<T>::dot(Matrix<T2> const& other)







    share|improve this answer





























      3
















      The syntax is wrong. You have a function template with template parameter T2 within a class template with template parameter T . It has to be defined like this:



      template<class T>
      template<class T2>
      auto Matrix<T>::dot(Matrix<T2> const& other)







      share|improve this answer



























        3














        3










        3









        The syntax is wrong. You have a function template with template parameter T2 within a class template with template parameter T . It has to be defined like this:



        template<class T>
        template<class T2>
        auto Matrix<T>::dot(Matrix<T2> const& other)







        share|improve this answer













        The syntax is wrong. You have a function template with template parameter T2 within a class template with template parameter T . It has to be defined like this:



        template<class T>
        template<class T2>
        auto Matrix<T>::dot(Matrix<T2> const& other)








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 11:17









        P.WP.W

        22.2k4 gold badges23 silver badges61 bronze badges




        22.2k4 gold badges23 silver badges61 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55396217%2ftemplate-member-of-template-class-implementation-in-header-file%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript