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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:43:15+00:00 2026-06-02T11:43:15+00:00

I am trying to write an exception class convinient to use with a constructor

  • 0

I am trying to write an exception class convinient to use with a constructor behaved like printf, example:

class ExcBase
{
    ExcBase(const char *fmt, ...)
    {
        // call things like vsprintf
    }
};

but inheritance of construct does not seem available in c++, so I want write a inherited class like:

class ExcChild : public ExcBase
{
    ExcChild(const char *fmt, ...)
       : ExcBase(fmt, ...) // XXX: how to pass the trailing parameters to the constructor?
    {
    }
};

or I will have to write the same constructor for all the child classes, and that was too annoying…

this question troubles me a lot, and I can not figure out a way to solve this…
any information will be a great help…

  • 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-02T11:43:16+00:00Added an answer on June 2, 2026 at 11:43 am

    If you separate out the complicated work into a function that takes a va_list argument, you should be able to call that from each child constructor (which you’d still have to implement for each child type). Then your duplicated code (per class) would just be declaring va_list, then calling va_start, your new (base) function, and va_end. There’s a post here on SO about doing that.

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

Sidebar

Related Questions

For training, I'm trying to write a class like std::string. I have read that
Im' trying to write a class BrokenObjectException class derivated from Exception. But in Eclipse
I am having trouble with XMLTextWriter.WriteStartElement throwing an exception: System.InvalidOperationException when trying to write
Trying to write a chat, like on facebook, I wondered if two clients can
I am trying to write shell script to read the value from /sys/class/net/eth0/carrier but
I am trying to write a stand alone Class that can be imported. As
I'm trying to write code like this: assert_throws(:ExtractionFailed) { unit.extract_from('5 x 2005')} ExtractionFailed is
I am trying to write a Java class to extract a large zip file
I'm trying to write a class which works in the same way as the
I was just trying to write the simple benchmark - public class IntegerCompareBenchmark extends

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.