This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Optional parameter in derived classes


Hi all,

i've learned that it is not neccessary to have the same default values
(or any default value at all) by overriding methods.
That means the following is legal:

class Base {
public:
  virtual void foo(int param = 0) = 0;
};

class A : public Base {
public:
  void foo(int param);
};

class B : public Base {
public:
  void foo(int param = 4711);
};

I had expected that one *MUST* use the same default values while
overriding methods with optional parameters.
Is there any warning switch which gives me a hint, that i'm overriding a
method with optional parameters in a different manner?

Thanks and greetings
Matthias Oltmanns

-- 
Matthias Oltmanns

Tel: 04421-1543-274
mail: Mathias.Oltmanns.Oltmanns@sysde.eads.net


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]