*** empty log message ***
This commit is contained in:
parent
1026a2c16d
commit
19c7912811
2 changed files with 60 additions and 2 deletions
4
202.tex
4
202.tex
|
@ -1,5 +1,5 @@
|
|||
\documentclass{article}
|
||||
\author{G.~Weigt}
|
||||
%\author{gweigt}
|
||||
\title{Note on SMP safety}
|
||||
\date{\today}
|
||||
\begin{document}
|
||||
|
@ -117,4 +117,4 @@ the resulting file \verb$test.s$:
|
|||
|
||||
|
||||
|
||||
\end{document}
|
||||
\end{document}
|
||||
|
|
58
203.tex
Normal file
58
203.tex
Normal file
|
@ -0,0 +1,58 @@
|
|||
\documentclass{article}
|
||||
\begin{document}
|
||||
|
||||
\section*{Virtual inheritance}
|
||||
|
||||
Let $baz$ inherit from $A$ and $B$.
|
||||
If both $A$ and $B$ inherit $foo$ virtually,
|
||||
then an instantiation of $baz$ has only one $foo$.
|
||||
|
||||
\medskip
|
||||
\noindent
|
||||
\begin{verbatim}
|
||||
#include <stdio.h>
|
||||
|
||||
class foo
|
||||
{
|
||||
public:
|
||||
int whatever;
|
||||
};
|
||||
|
||||
class A : public virtual foo
|
||||
{
|
||||
public:
|
||||
int a;
|
||||
};
|
||||
|
||||
class B : public virtual foo
|
||||
{
|
||||
public:
|
||||
int b;
|
||||
};
|
||||
|
||||
class baz : public A, public B
|
||||
{
|
||||
public:
|
||||
int c;
|
||||
};
|
||||
|
||||
main()
|
||||
{
|
||||
baz z;
|
||||
z.A::whatever = 1;
|
||||
z.B::whatever = 2;
|
||||
printf("%d %d\n", z.A::whatever, z.B::whatever);
|
||||
}
|
||||
\end{verbatim}
|
||||
|
||||
\medskip
|
||||
\noindent
|
||||
The result of running this program is
|
||||
|
||||
\medskip
|
||||
\noindent
|
||||
\begin{verbatim}
|
||||
2 2
|
||||
\end{verbatim}
|
||||
|
||||
\end{document}
|
Loading…
Add table
Reference in a new issue