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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:48:29+00:00 2026-06-11T03:48:29+00:00

EDIT: This is just another case silly & uninteresting mistake. You’ve been warned :)

  • 0

EDIT: This is just another case “silly & uninteresting mistake”. You’ve been warned 🙂

Here’s something that’s been keeping me up at night. Maybe someone with higher C++ knowledge can find how to get this to work:

template<class T>
class Base
{
    virtual void Method ( T* arg ) = 0;
};

class Child : public Base<MyType>
{
    void Method ( MyType* arg ) { /*blah*/ };
};

This doesn’t compile (at least on VS2008 it doesn’t) because it can’t match the two Methods together.

Currently we get around it by using a BaseType instead of MyType in the Method declaration and then cast BaseType to MyType in the Child implementation of the Method (We still need the MyType as a template for other stuff inside the base class).

Still it would be nice to be able to use the templated type directly.

EDIT:
Thanks guys it seems that fixing other errors (that were listed after) made it all work.
I did have template<class T> instead of template<T> in my original code as well as the Method listed as public.
It shows that I should have waited longer before posting. I apologize for that.

  • 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-11T03:48:30+00:00Added an answer on June 11, 2026 at 3:48 am

    Here is full example that compiles and works fine :

    struct MyType
    {
    };
    
    template< class T>
    class Base
    {
    public:
        virtual void Method ( T* arg ) = 0;
    };
    
    class Child : public Base<MyType>
    {
      public:
        void Method ( MyType*  ) { /*blah*/ };
    };
    
    
    int main()
    {
      MyType a;
      Child b;
    
      b.Method( &a );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Just to make things clear, this problem was caused by a typo in
[edit]: I'm terribly sorry for my timing on asking this question. I've just discovered
** EDIT ** Nevermind, just needed to take out the parens... I get this
edit alright, I guess C is painful in nature--Just, this part, is particularly painful.
edit This question is solved! Having something weird. I'm using html { font-size: 100%
Edit : Comments at bottom. Also, this . Here's what's kind of confusing me.
This is another design pattern in some legacy code that I couldn't find much
I have a variable in a package ( rec in this case) that needs
Use case is this: I want to unit test (in browser, QUnit or something
Edit: This problem was down to me passing the wrong view to the Touch

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.