J
jason.cipriani
If I have a base class with a constructor that takes '...' parameters,
and I want to derive a class from that and give it a similar
constructor and have it pass the variable parameters to the base, is
there a way to do that?
For example:
class Base {
public:
Base (const char *str, ...);
};
class Derived : public Base {
public:
Derived (const char *str, ...);
};
I want to have Derived's constructor call Base's constructor, passing
all the optional parameters. Right now I am splitting things up into a
separate initialization function that takes a va_list, but I'd really
like to avoid having to separate it out:
class Base {
public:
Base (void);
Base (const char *str, ...); // <-- this would call Init()
protected:
void Init (va_list args);
};
class Derived : public Base {
public:
Derived (const char *str, ...) {
// call's Base Init with va_list...
va_list args;
va_start(args, str);
Init(args);
va_end(args);
}
};
Thanks,
Jason
and I want to derive a class from that and give it a similar
constructor and have it pass the variable parameters to the base, is
there a way to do that?
For example:
class Base {
public:
Base (const char *str, ...);
};
class Derived : public Base {
public:
Derived (const char *str, ...);
};
I want to have Derived's constructor call Base's constructor, passing
all the optional parameters. Right now I am splitting things up into a
separate initialization function that takes a va_list, but I'd really
like to avoid having to separate it out:
class Base {
public:
Base (void);
Base (const char *str, ...); // <-- this would call Init()
protected:
void Init (va_list args);
};
class Derived : public Base {
public:
Derived (const char *str, ...) {
// call's Base Init with va_list...
va_list args;
va_start(args, str);
Init(args);
va_end(args);
}
};
Thanks,
Jason