Inheriting from class with variable args constructor

Started by
1 comment, last by Neophyte 21 years, 2 months ago
I have an exception class whose constructor basically looks like this: error::error ( const char* fmt, ... ); I''d like to use this class as a base-class for an exception-class hierarchy. The problem is that I haven''t been able to figure out a way to make an inheriting class call the base class constructor properly, and I really don''t want to reimplement the error::error constructor in the inheriting classes. I''d appreciate some insight into this, or some alternative solution to using ... in the base class constructor. -Neophyte
Advertisement
quote:Original post by Neophyte
I have an exception class whose constructor basically looks like this:
error::error ( const char* fmt, ... );

The ellipsis doesn''t have any place in C++ programs, other than as a catch-all function overload in certain template idioms.
quote:
I''d appreciate some insight into this, or some alternative solution to using ... in the base class constructor.

Don''t have a class called "error" responsible for string formatting. Use the stringstream class for formatting the string, either by passing a ready-formatted string into error, or by passing the details into error and having it format the string internally.
SabreMan: Thanks for input, and after thinking a little more clearly about things I redesigned and got rid of those pesky ellipsis.

quote:
The ellipsis doesn''t have any place in C++ programs, other than as a catch-all function overload in certain template idioms.

Sounds interesting. Any links and/or references on this?

-Neophyte

This topic is closed to new replies.

Advertisement