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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:07:27+00:00 2026-05-20T10:07:27+00:00

I am testing out a property system and I want to make sure that

  • 0

I am testing out a property system and I want to make sure that the root class can hold function pointers to the most derived class that there is. As a result I have something that is sort of working. The most derived class is currently working (RC2), but the current middle class (RC1) will have a compiler error. I want to be able to instantiate RC1 and RC2. The compiler error I will get with RC when creating it is (for the line of RC1<RC1> rc1test;)

error C2955: ‘RC1’ : use of class template requires template argument list

error C3203: ‘RC1’ : unspecialized class template can’t be used as a template argument for template parameter ‘PropertyOwner’, expected a real type

I tried to do RC1<> rc1test; but that did not help either. Here is the source, does anyone have any suggestions?

#include <iostream>
#include <map>
#include <string>
using namespace std;

template<class T, class BaseClass>
class RBase : public BaseClass
{
public:
  typedef int (T::*GetFP)(void) const;

protected:
  std::map<const char*, GetFP> mGetFPs;

};

class CBase
{

};

template<class PropertyOwner>
class RC1;

template<class PropertyOwner=RC1>
class RC1 : public RBase<PropertyOwner, CBase>
{
public:
  int int1(void) const
  {
    return 1;
  }

  RC1()
  {
    mGetFPs.insert( pair<const char*, GetFP>("RC1I1I", &PropertyOwner::int1) );
  };

  virtual void inspection(void)
  {
    int test = 0;
  }
};

class RC2 : public RC1<RC2>
{
public:
  int int2(void) const
  {
    return 2;
  }

  RC2()
  {
    mGetFPs.insert( pair<const char*, GetFP>("RC2I2I", &RC2::int2) );
  };

  virtual void inspection(void)
  {
    int test = 0;
  }
};

int main(void)
{
  RC1<RC1> rc1test;
  
  RC2 rc2test;
  rc2test.inspection();

  return(0);
}
  • 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-05-20T10:07:28+00:00Added an answer on May 20, 2026 at 10:07 am

    If you can use boost then you might be able to do a cleaner approach using boost::function and boost::bind to get the pointers you want.

        template <typename BC>
        class RBase : public BC
        {
        public:
            typedef int FunctionSignature (void) const;
            typedef boost::function<FunctionSignature> CallbackFunction;
        protected:
            std::map<const char*, CallbackFunction> mGetFPs;
        };
    
        class CBase
        {
        };
    
        class RC1 : public RBase<CBase>
        {
        public:
            RC1 () 
            { 
                mGetFPs.insert ( std::make_pair ( "RC1I1I", 
                                                  boost::bind ( &RC1::int1, this ) ) );
            }
            int int1(void) const { return 1; }
        };
    
    
        class RC2 : public RC1
        {
        public:
            RC2 () 
            { 
                mGetFPs.insert ( std::make_pair ( "RC2I2I", 
                                                  boost::bind ( &RC2::int2, this ) ) );
            }
            int int2(void) const { return 2; }
        };
    

    In fact, you can assign ANY function that has the proper signature to the boost::function and even use boost::bind to adapt functions that have additional parameters (see below).

        class RC3 : public RC1
        {
        public:
            RC3 () 
            { 
                mGetFPs.insert ( std::make_pair ( "RC3I3I", 
                                                  boost::bind ( &RC3::intN, this, 3 ) ) );
            }
            int intN(int n) const { return n; }
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In testing out our API, one of our testers found out that when they
I was testing out the db2 max function to see if it picks NULL
I am unit testing a class with a property whose value changes often, depending
I'm implimenting my own ApplicationContext class that uses the singleton pattern. I want to
I've finally figured out how to make all my millions of tabs (not that
Testing out someone elses code, I noticed a few JSP pages printing funky non-ASCII
I'm testing out faults and exception handling on my service and am seeing odd
I was testing out RQ (Redis-Queue) when after running the command rqworker and testing
I'm testing out the OpenERP 6.1 web client, and I sometimes have a sales
i'm just testing out the csv component in python, and i am having some

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.