Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Neophyte

Inheriting from class with variable args constructor

This topic is 5589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!