Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

gutsyfarid

@gutsyfarid
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Polymorphism in C++
    G gutsyfarid

    PROBLEM Unable to understand the variation in size of object All the code is tested under Borland C++ ver 3.1 In borland V3.1 the int takes two bytes Lets look at the following code Class base { public: int b; base() {} virtual void f() {} virtual void g() {} }; Class derive : virtual public base { public: int d; derive() {} virtual void f() {} virtual void g() {} }; ……………… derive d; cout<gives 12 why? /* But if I don’t give constructors in derive then the size of derive class object is 10, because there will be no 2 bytes extra in object layout as shown below. Please help me out about finding the myth of these extra two bytes. */

     Object-Layout            V-TABLE
        |------------|          |------------|
     ---|ptr to base |       -->|derive::f   |	
     |  |------------|       |  |------------|
     |  |derive v-ptr|-------|  |derive::k   | 
     |  |------------|          |------------|
     |  |d           |        ->|derive::f   |
     |  |------------|        | |------------|
     |  |0           |<--     | |base::g     |
     |  |------------|   |    | |------------|
     -->|base-vptr   |---|----|	
        |------------|   |	
        |b           |   |
        |------------|   |**what the hell is this**
    

    Please reply at: Contact: informfarid@yahoo.com ------------------------------------------------------------ In the middle of dificulty lies oppurtunity.

    C / C++ / MFC help c++ delphi com oop

  • Polymorphism in C++
    G gutsyfarid

    Sir, I am student of Punjab University College of Information Technology, Lahore, Pakistan I have problem while using Borland C++ v3.1. Problem: ========= The size of an object in virtual inheritance increases 2 bytes Class base { public: int b; base() {} virtual void f() {} virtual void g() {} }; Class derive : virtual public base { public: int d; derive() {} virtual void f() {} virtual void g() {} }; ---------------------- derive d; cout<The object layout in figure is in following URL [OBJECT LAYOUT FIGURE](<a href=) */ The object layout where that extra 2 bytes are laid is drawn in atttchment with v-table layout. Please contact me at! informfarid@yahoo.com

    C / C++ / MFC oop c++ delphi com help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups