Re: ansi status of 'using'

From: Ioannis Vranos (ivr_at_guesswh.at.grad.com)
Date: 05/05/04


Date: Wed, 5 May 2004 09:52:56 +0300


"Mark Huppert" <dustyoso@netspeed.com.au> wrote in message
news:40988873$1@mail.netspeed.com.au...
> Dear Colleagues
>
> re: 'using' and the ANSI C++ standard
>
> According to the ANSI C++ standard, is this a valid
> way (disregarding whether it is 'naughty') of converting a
> public method in the base class into a private method in the child class?
> My g++ compiler ignores this without comment.
>
> class parent{
> public:
> double length(double num) {return num; }
> };
>
> class child: public parent {
> public:
> double hiding(double num) {return length(num);}
> private:
> using parent::length;
> };
>
> ie, equivalent to:
> private:
> double length(double num) {return parent::length(num); }

No, but why doing this? You can do:

class parent{
   public:
       double length(double num) {return num; }
};

class child: private parent {
  public:
      double hiding(double num) {return length(num);}
};

Regards,

Ioannis Vranos



Relevant Pages

  • virtual slicing problem using std::vector<someclass>
    ... virtual void print() { ... class child: public parent { ...
    (comp.lang.cpp)
  • Re: Problem Blocking operator=
    ... > class Child: public Parent ... > With gcc 3.2, this failed to link, with undefined references ...
    (comp.lang.cpp)
  • Re: Problem Blocking operator=
    ... > With gcc 3.2, this failed to link, with undefined references ... I think that's normal for virtual functions. ...
    (comp.lang.cpp)
  • Re: ansi status of using
    ... > public method in the base class into a private method in the child class? ...
    (comp.lang.cpp)
  • Re: OOP???
    ... >> of class Parent ... but you can't override it. ... > If replying to the group, please do not mail me too ...
    (microsoft.public.dotnet.languages.csharp)