add ipi10
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
\documentclass[uebung]{../../../lecture}
|
||||
|
||||
\title{IPI: Übungsblatt 10}
|
||||
\author{Samuel Weidemaier, Christian Merten}
|
||||
|
||||
\usepackage[]{listings}
|
||||
|
||||
\usepackage{xcolor}
|
||||
|
||||
\lstdefinestyle{mystyle}{
|
||||
commentstyle=\color{gray},
|
||||
language=C++,
|
||||
keywordstyle=\color{blue},
|
||||
numberstyle=\tiny\color{gray},
|
||||
stringstyle=\color{black},
|
||||
basicstyle=\ttfamily\footnotesize,
|
||||
breakatwhitespace=false,
|
||||
breaklines=true,
|
||||
captionpos=b,
|
||||
keepspaces=true,
|
||||
numbers=left,
|
||||
numbersep=5pt,
|
||||
showspaces=false,
|
||||
showstringspaces=false,
|
||||
showtabs=false,
|
||||
tabsize=2
|
||||
}
|
||||
|
||||
\lstset{style=mystyle}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\begin{aufgabe}
|
||||
siehe \textit{readfiles.cpp}
|
||||
\end{aufgabe}
|
||||
|
||||
\begin{aufgabe}
|
||||
\begin{lstlisting}[language=C++, title=Fehlersuche, captionpos=b]
|
||||
#include <iostream>
|
||||
class A
|
||||
{
|
||||
public:
|
||||
int ap;
|
||||
void X();
|
||||
private:
|
||||
int aq;
|
||||
void aX();
|
||||
};
|
||||
|
||||
class B : public A
|
||||
{
|
||||
public:
|
||||
int bp;
|
||||
void Y();
|
||||
private:
|
||||
int bq;
|
||||
void bY();
|
||||
};
|
||||
|
||||
class C : public B
|
||||
{
|
||||
public:
|
||||
int cp;
|
||||
void Z();
|
||||
private:
|
||||
int cq;
|
||||
void cZ();
|
||||
};
|
||||
|
||||
void A::X() { };
|
||||
void A::aX() { };
|
||||
void B::bY() { };
|
||||
void C::Z() { };
|
||||
|
||||
void B::Y()
|
||||
{
|
||||
bq = bp;
|
||||
aq = ap; // Fehler: A::aq ist privat, also in B nicht sichtbar
|
||||
bY();
|
||||
}
|
||||
|
||||
void C::cZ()
|
||||
{
|
||||
ap = 1;
|
||||
bp = 2;
|
||||
cq = 3;
|
||||
X();
|
||||
Y();
|
||||
aX(); // Fehler: A::aX() ist privat, also in C nicht sichtbar
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
A a; B b; C c;
|
||||
|
||||
a.X();
|
||||
b.bY(); // Fehler: B::bY() ist privat, also hier nicht sichtbar
|
||||
c.cp = 4;
|
||||
c.bp = 1;
|
||||
c.ap = 2;
|
||||
c.aq = 5; // Fehler: A::aq ist privat, in C nicht sichtbar und erst recht nicht hier
|
||||
|
||||
b.ap = c.ap;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\end{lstlisting}
|
||||
\end{aufgabe}
|
||||
|
||||
\end{document}
|
||||
Reference in New Issue
Block a user