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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:38:27+00:00 2026-06-02T00:38:27+00:00

I have a templated base class that provides a method remove(). I have a

  • 0

I have a templated base class that provides a method remove(). I have a class derived from the templated base class that does not hide the remove() method. However, the templated based classes’ remove method isn’t visible. Why? And is there a way to resolve this (I mean other than the ‘trick’ I figured out at the very end)?

I’ve stripped this down to a small code example:


#include <map>
#include <iostream>
#include <boost/shared_ptr.hpp>



// Common cache base class. All our caches use a map, expect children to
// specify their own add, remove and modify methods, but the base supplies a
// single commont remove too.
template <class T>
class cache_base {
public:

    cache_base () {};

    virtual ~cache_base() {};

    virtual void add(uint32_t    id) = 0;

    virtual void remove(uint32_t    id) = 0;

    void remove() {
        std::cout << "This is base remove\n";
    };

    virtual void modify(uint32_t    id) = 0;

protected:
    typedef std::map< uint32_t, typename T::SHARED_PTR_T>    DB_MAP_T;

    DB_MAP_T    m_map;
};


// A dummy item to be managed by the cache.
class dummy {
public:
    typedef    boost::shared_ptr<dummy>    SHARED_PTR_T;

    dummy () {};
    ~dummy () {};
};


// A dummy cache
class dummy_cache :
    public cache_base<dummy>
{
public:
    dummy_cache () {};

    virtual ~dummy_cache () {};

    virtual void add(uint32_t    id) {};

    virtual void remove(uint32_t    id) {};

    virtual void modify(uint32_t    id) {};
};




int
main ()
{
    dummy_cache    D;

    D.remove();

    return(0);
}

This code fails to compile, giving me the following errors


g++ -g -c -MD -Wall -Werror -I /views/LU-7.0-DRHA-DYNAMIC/server/CommonLib/lib/../include/ typedef.cxx
typedef.cxx: In function 'int main()':
typedef.cxx:67: error: no matching function for call to 'dummy_cache::remove()'
typedef.cxx:54: note: candidates are: virtual void dummy_cache::remove(uint32_t)
make: *** [typedef.o] Error 1

I don’t know if it makes a difference but I am using g++ version 4.1.2 20070115.

Also, I found that if I added the following remove method to the dummy_cache it works. However, it feels odd that I have to add an a subordinate method in the dummy_cache to expose a public base method.

void remove () {return cache_base<dummy>::remove(); }
  • 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-02T00:38:29+00:00Added an answer on June 2, 2026 at 12:38 am

    Your overloaded dummy_cache::remove(uint32_t) is hiding the cache_base::remove(). You can unhide with:

    class dummy_cache :
        public cache_base<dummy>
    {
    public:
      using cache_base<dummy>::remove;
      ...
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class, A , in C++/CLI which derives from a templated base
Say I have an abstract base class that has a method to generate Foo
I have a tempated base class check and publically derived class childcheck. the base
I have a templated container class that looks something like this: template <class ItemType>
I have policies that derive from a base policy. Some classes specialize for the
I have an abstract class defining a pure virtual method in c++: class Base
I have an abstract generic view-model that I use as a base-class for several
I have two classes, Base and Derived . I provide a function that applies
I have the following problem with inheritance and templates: class Base {}; class Deriv
I have a base.html template that contains a list of links. Example: <div id=sidebar1>

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.