c++

Discussion in 'Programming' started by Official Techie, Sep 16, 2006.

Thread Status:
Not open for further replies.
  1. Official Techie

    Official Techie New Member

    Joined:
    Jan 25, 2005
    Messages:
    439
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Somewhere in motherboard
    class stationary
    {
    char type;
    char manufacturer[10];
    public :
    stationary();
    void Read_sta_details();
    void Disp_Sta_details();
    };

    class office : public stationary
    {
    int no_of_types;
    float cost_of_sta;
    public:
    void Read_off_details();
    void Disp_off_details();
    };

    class printer : private office
    {
    int no_of_users;
    char delivery_date[10];
    public:
    void Read_pri_details();
    void Disp_pri_details();
    };

    void main()
    {
    printer Myprinter;
    }

    what is the size of Myprinter in bytes ??
     
  2. OP
    OP
    Official Techie

    Official Techie New Member

    Joined:
    Jan 25, 2005
    Messages:
    439
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Somewhere in motherboard
    no one answered
     
  3. OP
    OP
    Official Techie

    Official Techie New Member

    Joined:
    Jan 25, 2005
    Messages:
    439
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Somewhere in motherboard
    no no u did not got the point the prog which i had written has come in 2005 board exams how can i write it in computer then i want to know as it is
     
  4. varkey

    varkey New Member

    Joined:
    Nov 12, 2004
    Messages:
    122
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Cochin, Kerala
    i think its 30 bytes


    edit : its 29 bytes. counted the first char as 2 bytes.
     
    Last edited: Sep 22, 2006
  5. romeo_8693

    romeo_8693 "The RaCaLaNGeL"©

    Joined:
    Dec 23, 2005
    Messages:
    389
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Goa/Pune
    ooops!! yup its 29 bytes......
     
    Last edited: Sep 24, 2006
  6. altimate

    altimate New Member

    Joined:
    Aug 31, 2006
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    0
    (1+10)+(2+4)+(2+10)=29 bytes
    and bingo!!!!!!!!!!
     
  7. OP
    OP
    Official Techie

    Official Techie New Member

    Joined:
    Jan 25, 2005
    Messages:
    439
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Somewhere in motherboard
    3 answers which one is correct whats the funda aise hi chalta raha to computer ke exam mein to pakka fail ho jaonga boards mein
     
  8. ilugd

    ilugd Beware of the innocent

    Joined:
    Dec 25, 2005
    Messages:
    1,009
    Likes Received:
    3
    Trophy Points:
    0
    LOL. Ever tried running that code ms123 posted?
     
  9. mod-the-pc

    mod-the-pc Back to School Mr. Bean !

    Joined:
    Apr 1, 2004
    Messages:
    344
    Likes Received:
    5
    Trophy Points:
    18
    Location:
    Chennai
    Its 12 bytes. Note that private members are not inherited
     
  10. casanova

    casanova The Frozen Nova

    Joined:
    Sep 25, 2004
    Messages:
    1,641
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    Trespasser in Virtual Land
    Yup, it is 12 bytes.
     
  11. varkey

    varkey New Member

    Joined:
    Nov 12, 2004
    Messages:
    122
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Cochin, Kerala
    as "altimate" said its 29 bytes. eventhough some are private members they are accessible thru the functions which are inherited.
     
  12. mod-the-pc

    mod-the-pc Back to School Mr. Bean !

    Joined:
    Apr 1, 2004
    Messages:
    344
    Likes Received:
    5
    Trophy Points:
    18
    Location:
    Chennai
    Yes I tested this and its 29 bytes. But I'm still not sure how the members that are not inherited add to the size of the derived class...:confused:
     
Thread Status:
Not open for further replies.

Share This Page