A question of IS-A and proper inheritance (this could be a troll... ;-) )

From: Alf P. Steinbach (alfps_at_start.no)
Date: 03/14/04


Date: Sun, 14 Mar 2004 09:01:57 GMT

I recently just typed in, in a hurry,

    class ColorSpec
    {
    public:
        typedef unsigned char Byte;

    private:
        Byte myRed, myGreen, myBlue, myAlpha;

    public:
        ColorSpec( Byte r, Byte g, Byte b, Byte a = 0 )
        : myRed( r ), myGreen( g ), myBlue( b ), myAlpha( a )
        {}

        Byte r() const { return myRed; }
        Byte g() const { return myGreen; }
        Byte b() const { return myBlue; }
        Byte a() const { return myAlpha; }
    }; // class ColorSpec

    class OpaqueColorSpec: public ColorSpec
    {
    public:
        OpaqueColorSpec( Byte r, Byte g, Byte b )
        : ColorSpec( r, g, b, 0 )
        {}
    }; // class OpaqueColorSpec

In fact I think this is what I'd ended up with also if I'd invested
time to think about it.

But what do you folks think?

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Relevant Pages

  • Re: temple/pyramid plans
    ... Usenet, no one on an unmoderated group can be stopped from posting. ... It might be that some folks here might also be ... explain your approach and your top-posting. ...
    (sci.archaeology)
  • Re: Email
    ... The only difference is that Outlook must be running at the time the ... Because it messes up the order in which people normally read text. ... Why is top-posting such a bad thing? ... What is the most annoying thing on usenet and in e-mail? ...
    (microsoft.public.outlook)
  • Re: Adobe PS Elements 2
    ... Well first clue is that you just top posted. ... Because it messes up the order in which people normally read text. ... Why is top-posting such a bad thing? ... What is the most annoying thing on usenet and in e-mail? ...
    (rec.photo.digital.slr-systems)
  • Re: Newest VC 7.1 version?
    ... > And the problem you decribe have I never seen in this newsgroups. ... Because it messes up the order in which people normally read text. ... Why is top-posting such a bad thing? ... What is the most annoying thing on usenet and in e-mail? ...
    (microsoft.public.dotnet.general)
  • A question of IS-A and proper inheritance (this could be a troll... ;-) )
    ... But what do you folks think? ... Because it messes up the order in which people normally read text. ... Why is top-posting such a bad thing? ... What is the most annoying thing on usenet and in e-mail? ...
    (comp.lang.cpp)