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

  • Home
  • SEARCH
  • 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 7635851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:31:48+00:00 2026-05-31T07:31:48+00:00

I am developing a simple data to XML serializer for training purposes. Now that

  • 0

I am developing a simple data to XML serializer for training purposes. Now that I have my base class of a serializer done, I want to derive a specialized serializer for the data structures of different projects. My base serializer has functions like this:

class Serializer {
public:
    template <class T> void add_value(const std::string &key, T *value);
    template <class T> void add_value(const std::string &key, std::vector<T*> *value);
};

The base serializer is able to handle most primitive data structures (int, double, bool, etc.) and there are some overloads for a few more complex structures (vectors, maps, etc.). Lets assume I now have a project with the following data structure:

struct MyStruct {
    int width, height;
};

I would now like to derive a serializer from my base serializer that is able to handle that structure, as well as the structures it already knows:

class MyStructSerializer : public Serializer {
    void add_value(const std::string &key, MyStruct *value);
};

Problem is: After overloading the add_value function in the child class, the parent class forms of it are no longer available. Is it possible to overload the add_value function as a specialization to the functions provided in the parent class, i.e. keep the child class from forgetting the more general method of its parent after overloading?

  • 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-31T07:31:49+00:00Added an answer on May 31, 2026 at 7:31 am

    The using keyword will import members of the base class into the derived class:

    include <vector>
    #include <string>
    #include <iostream>
    // Note: __PRETTY_FUNCTION__ is non-standard
    #define X(x) (std::cout << __PRETTY_FUNCTION__ << "\n")
    class Serializer {
    public:
      template <class T> void add_value(const std::string &key, T *value)
        { X(); }
      template <class T> void add_value(const std::string &key, std::vector<T*> *value)
        { X(); }
    };
    
    struct MyStruct {
        int width, height;
    };
    
    class MyStructSerializer : public Serializer {
    public:
        using Serializer::add_value;
        void add_value(const std::string &key, MyStruct *value)
          { X(); }
    };
    
    int main () {
      MyStructSerializer s;
      MyStruct ms;
      int i;
      s.add_value("Hello", &i);
      s.add_value("Hello", &ms);
    }
    

    Although, wouldn’t it be easier to specialize Serializer::add_value, rather than derive from Serializer? Like this:

    template <>
    void Serializer::add_value<MyStruct>(const std::string &key, MyStruct* value)
    {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a desktop Mac OS X App that saves its very simple data
I'm developing a simple application that fetches some data from wowarmory.com. What I need
I developing the simple UIApplication in which i want to crop the UIImage (in
Hi I am developing a simple application based upon ASP.NET MVC. I have altered
I'm developing simple Windows Service sending and receiving data from remote web service. I
I'm developing a simple servlet/JSP, data-driven web site on Google App Engine. I've started
I am currently developing a simple info app on various university campuses. I want
I'm developing an iPhone application that will access XML files (or something similar) from
I started developing simple application in WPF and XAML. I want to try accessign
I'm developing a simple form with Secha Touch. I have defined a DataStore for

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.