You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
6.1 KiB
HTML
125 lines
6.1 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- Copyright (C) 1992-2019 Free Software Foundation, Inc.
|
|
Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
|
|
and David MacKenzie.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with no
|
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
|
Texts. A copy of the license is included in the section entitled "GNU
|
|
Free Documentation License". -->
|
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Virtual Base Classes (STABS)</title>
|
|
|
|
<meta name="description" content="Virtual Base Classes (STABS)">
|
|
<meta name="keywords" content="Virtual Base Classes (STABS)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link href="index.html#Top" rel="start" title="Top">
|
|
<link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Cplusplus.html#Cplusplus" rel="up" title="Cplusplus">
|
|
<link href="Static-Members.html#Static-Members" rel="next" title="Static Members">
|
|
<link href="Inheritance.html#Inheritance" rel="prev" title="Inheritance">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
div.smalllisp {margin-left: 3.2em}
|
|
kbd {font-style: oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
|
pre.smallexample {font-size: smaller}
|
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
|
pre.smalllisp {font-size: smaller}
|
|
span.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<a name="Virtual-Base-Classes"></a>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Static-Members.html#Static-Members" accesskey="n" rel="next">Static Members</a>, Previous: <a href="Inheritance.html#Inheritance" accesskey="p" rel="prev">Inheritance</a>, Up: <a href="Cplusplus.html#Cplusplus" accesskey="u" rel="up">Cplusplus</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<hr>
|
|
<a name="Virtual-Base-Classes-1"></a>
|
|
<h3 class="section">8.13 Virtual Base Classes</h3>
|
|
|
|
<p>A derived class object consists of a concatenation in memory of the data
|
|
areas defined by each base class, starting with the leftmost and ending
|
|
with the rightmost in the list of base classes. The exception to this
|
|
rule is for virtual inheritance. In the example above, class <code>D</code>
|
|
inherits virtually from base class <code>B</code>. This means that an
|
|
instance of a <code>D</code> object will not contain its own <code>B</code> part but
|
|
merely a pointer to a <code>B</code> part, known as a virtual base pointer.
|
|
</p>
|
|
<p>In a derived class stab, the base offset part of the derivation
|
|
information, described above, shows how the base class parts are
|
|
ordered. The base offset for a virtual base class is always given as 0.
|
|
Notice that the base offset for <code>B</code> is given as 0 even though
|
|
<code>B</code> is not the first base class. The first base class <code>A</code>
|
|
starts at offset 0.
|
|
</p>
|
|
<p>The field information part of the stab for class <code>D</code> describes the field
|
|
which is the pointer to the virtual base class <code>B</code>. The vbase pointer
|
|
name is ‘<samp>$vb</samp>’ followed by a type reference to the virtual base class.
|
|
Since the type id for <code>B</code> in this example is 25, the vbase pointer name
|
|
is ‘<samp>$vb25</samp>’.
|
|
</p>
|
|
<div class="smallexample">
|
|
<pre class="smallexample">.stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,
|
|
160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;
|
|
2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt:
|
|
:32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
|
|
</pre></div>
|
|
|
|
<p>Following the name and a semicolon is a type reference describing the
|
|
type of the virtual base class pointer, in this case 24. Type 24 was
|
|
defined earlier as the type of the <code>B</code> class <code>this</code> pointer. The
|
|
<code>this</code> pointer for a class is a pointer to the class type.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">.stabs "this:P24=*25=xsB:",64,0,0,8
|
|
</pre></div>
|
|
|
|
<p>Finally the field offset part of the vbase pointer field description
|
|
shows that the vbase pointer is the first field in the <code>D</code> object,
|
|
before any data fields defined by the class. The layout of a <code>D</code>
|
|
class object is a follows, <code>Adat</code> at 0, the vtable pointer for
|
|
<code>A</code> at 32, <code>Cdat</code> at 64, the vtable pointer for C at 96, the
|
|
virtual base pointer for <code>B</code> at 128, and <code>Ddat</code> at 160.
|
|
</p>
|
|
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Static-Members.html#Static-Members" accesskey="n" rel="next">Static Members</a>, Previous: <a href="Inheritance.html#Inheritance" accesskey="p" rel="prev">Inheritance</a>, Up: <a href="Cplusplus.html#Cplusplus" accesskey="u" rel="up">Cplusplus</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|