Giter VIP home page Giter VIP logo

Comments (1)

ddwolf avatar ddwolf commented on June 21, 2024

And another question:), in the description

A class that contains a virtual pointer, but no other data except (possibly) virtual bases. In particular ...

What does virtual bases mean here? a dynamic base classs? or classes virtually inherited by the most derived class? I think it's the second explaination, but using gcc to dump-class-hierarchy will show that normally inherit from dynamic classes can make the most derived class nearly empty too, is there something wrong?
below code will show that a class NearlyEmpty2 which not virtually inherited from two dynamic classes is a nearly empty class.

cpp code

struct Empty {};
struct NearlyEmpty { virtual void d() {}};
struct NearlyEmpty2: public NearlyEmpty, public Empty {};

output of g++ -fdump-class-hierarchy NearlyEmpty.cpp

Class NearlyEmpty2
   size=8 align=8
   base size=8 base align=8
NearlyEmpty2 (0x0x7fc7eaeed460) 0 **nearly-empty**
    vptr=((& NearlyEmpty2::_ZTV12NearlyEmpty2) + 16u)
  NearlyEmpty (0x0x7fc7eb044720) 0 nearly-empty
      primary-for NearlyEmpty2 (0x0x7fc7eaeed460)
  Empty (0x0x7fc7eb044780) 0 empty

from cxx-abi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.