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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:02:58+00:00 2026-05-14T03:02:58+00:00

I got over a problem, I think a very specific one. I’ve got 2

  • 0

I got over a problem, I think a very specific one.

I’ve got 2 classes, a B aseclass and a D erived class (from B aseclass).
B is a template class ( or class template) and has a pure virtual method virtual void work(const T &dummy) = 0;
The D erived class is supposed to reimplement this, but as D is Derived from B rather than D being another template class, the compiler spits at me that virtual functions and templates don’t work at once.

Any ideas how to accomplish what I want?

I am thankfull for any thoughts and Ideas, especially if you allready worked out that problem

this class is fixed aka AS IS, I can not edit this without breaking existing code base

template <typename T>
class B {
public:
...
virtual void work(const T &dummy) = 0;
..
};

take int* as an example

class D : public B<int*>{
...
virtual void work(const int* &dummy){ /* put work code here */ }
..
};

Edit: The compiler tells me, that void B<T>::work(const T&) [with T = int*] is pure virtual within D

  • 1 1 Answer
  • 3 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-14T03:02:58+00:00Added an answer on May 14, 2026 at 3:02 am

    You placed the const in the wrong place. Try

    virtual void work(int* const &dummy){ /* put work code here */ }
    

    const int* is the same as int const*, i.e. it associates the const with the int and not the pointer.

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

Sidebar

Related Questions

Hi got a problem I can only think of solving in a very crude
I've got a very large SQLite table with over 500,000 rows with about 15
I've got a class that will undergo certain version changes over the course of
I've got a class with well over 100 properties (it's a database mapping class)
We've got a server over which we're running a Django powered site. Since we
In Django, I've got loggers all over the place, currently with hard-coded names. For
I'm working on an MFC application, that got pretty messy over years and over
I got an array which I iterate over and try to create a variable.
I've got a WinCE device powered over ethernet (PoE) and I want to prevent
Reading over the responses to this question Disadvantages of Test Driven Development? I got

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.