2020-04-20 12:25:52 +02:00
|
|
|
\documentclass[usenames,dvipsnames]{beamer}
|
2020-04-16 19:40:17 +02:00
|
|
|
%----------------------------------------------------------------------------------------
|
2020-04-20 12:25:52 +02:00
|
|
|
% Struktur und Pointer Referat
|
|
|
|
% 20.04.2020
|
2020-04-16 19:40:17 +02:00
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
\usetheme{focus} % Use the Focus theme supplied with the template
|
|
|
|
|
2020-04-17 11:01:58 +02:00
|
|
|
\usepackage[utf8]{inputenc}
|
|
|
|
|
2020-04-16 19:40:17 +02:00
|
|
|
\usepackage{booktabs}
|
|
|
|
\usepackage{amsmath}
|
|
|
|
\usepackage{hyperref}
|
2020-04-17 09:44:11 +02:00
|
|
|
\usepackage{graphicx}
|
|
|
|
\usepackage{listings} % Required for better table rules
|
2020-04-17 11:01:58 +02:00
|
|
|
\usepackage{xcolor}
|
|
|
|
|
|
|
|
% Farbdefinitionen
|
|
|
|
\definecolor{backgroundcoloreq}{RGB}{180,140,0}
|
|
|
|
\definecolor{codegreen}{rgb}{0,0.6,0}
|
|
|
|
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
|
|
|
|
\definecolor{codepurple}{rgb}{0.58,0,0.82}
|
|
|
|
\definecolor{codeorange}{RGB}{190,100,0}
|
|
|
|
|
|
|
|
|
|
|
|
\lstset{
|
|
|
|
language=C,
|
|
|
|
basicstyle=\ttfamily,
|
|
|
|
numbers=left,
|
|
|
|
numberstyle=\tiny,
|
|
|
|
tabsize=4,
|
|
|
|
columns=fixed,
|
|
|
|
showstringspaces=false,
|
|
|
|
showtabs=false,
|
|
|
|
breaklines=true,
|
|
|
|
keepspaces,
|
|
|
|
morekeywords={std},
|
|
|
|
keywordstyle=\color{blue}\ttfamily,
|
|
|
|
stringstyle=\color{red}\ttfamily,
|
|
|
|
commentstyle=\color{OliveGreen!85}\ttfamily,
|
|
|
|
numberstyle=\tiny\color{codegray},
|
2020-04-17 11:53:35 +02:00
|
|
|
basicstyle=\footnotesize\selectfont\ttfamily,
|
2020-04-17 11:01:58 +02:00
|
|
|
% keyword highlighting
|
|
|
|
classoffset=1, % starting new class
|
|
|
|
otherkeywords={>,<,.,;,-,+,!,=,~,:,[,],NULL,&},
|
|
|
|
morekeywords={>,<,.,;,-,+,!,=,~,:,[,],NULL,&},
|
|
|
|
keywordstyle=\color{codeorange},
|
|
|
|
classoffset=0
|
|
|
|
}
|
2020-04-16 19:40:17 +02:00
|
|
|
|
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
% TITLE SLIDE
|
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
\title{Strukturen + Pointer \\ Call by Reference/Value}
|
|
|
|
|
|
|
|
\subtitle{mit Anwendungsfälle / Programmierbeispiele}
|
|
|
|
|
|
|
|
\author{Lukas Heiligenbrunner}
|
|
|
|
|
|
|
|
\institute{HTL Steyr \\ Schlüsselhofgasse 63}
|
|
|
|
|
|
|
|
\date{\today}
|
|
|
|
|
|
|
|
%------------------------------------------------
|
|
|
|
|
|
|
|
\begin{document}
|
|
|
|
|
|
|
|
%------------------------------------------------
|
|
|
|
|
|
|
|
\begin{frame}
|
|
|
|
\maketitle % Automatically created using the information in the commands above
|
|
|
|
\end{frame}
|
|
|
|
|
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
% SECTION 1
|
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
|
2020-04-17 11:53:35 +02:00
|
|
|
|
2020-04-16 19:40:17 +02:00
|
|
|
\section{Strukturen} % Section title slide, unnumbered
|
|
|
|
|
|
|
|
%------------------------------------------------
|
|
|
|
|
|
|
|
\begin{frame}{Strukturen Allgemein}
|
2020-04-17 11:01:58 +02:00
|
|
|
\input{structallg.tex}
|
2020-04-16 19:40:17 +02:00
|
|
|
\end{frame}
|
|
|
|
|
|
|
|
%------------------------------------------------
|
|
|
|
|
2020-04-17 11:53:35 +02:00
|
|
|
\begin{frame}[fragile, allowframebreaks]{C Syntax}
|
|
|
|
Definition:
|
|
|
|
\begin{lstlisting}
|
|
|
|
struct Adresse {
|
|
|
|
char name[50];
|
2020-04-17 11:01:58 +02:00
|
|
|
char strasse[100];
|
|
|
|
short hausnummer;
|
|
|
|
long plz;
|
|
|
|
char stadt[50];
|
|
|
|
};
|
2020-04-17 11:53:35 +02:00
|
|
|
\end{lstlisting}
|
|
|
|
Anwendung:
|
|
|
|
\begin{lstlisting}
|
|
|
|
// Variable der Struktur erstellen
|
|
|
|
struct Adresse adresseKurt;
|
|
|
|
// Zugriff auf die Elemente
|
|
|
|
strcpy(adresseKurt.name, "Kurt Kanns");
|
|
|
|
adresseKurt.hausnummer = 23;
|
|
|
|
adresseKurt.plz = 45678;
|
|
|
|
\end{lstlisting}
|
|
|
|
|
|
|
|
\framebreak
|
|
|
|
|
|
|
|
Typdefinition mit typedef:
|
|
|
|
\begin{lstlisting}
|
|
|
|
typedef struct Adresse {
|
|
|
|
char name[50];
|
|
|
|
short hausnummer;
|
|
|
|
} ADR;
|
|
|
|
|
|
|
|
ADR a1,a2;
|
|
|
|
\end{lstlisting}
|
2020-04-16 19:40:17 +02:00
|
|
|
\end{frame}
|
|
|
|
|
2020-04-17 11:01:58 +02:00
|
|
|
\begin{frame}{Sonstiges}
|
|
|
|
\begin{itemize}
|
|
|
|
\item Strukturtypdeklaration: struct Adresse {…};
|
|
|
|
\item Gesamtlänge der Struktur: sizeof(Struktur)
|
|
|
|
\item Zugriff auf einzelne Komponenten durch\\
|
|
|
|
Punktnotation: Adresse1.Vorname = “Peter“;
|
|
|
|
\item Weitere Strukturen hinzufügen: struct Adresse Adresse5;
|
|
|
|
\item Weiteres hinzufügen von Komponenten während der Laufzeit nicht möglich.
|
|
|
|
\end{itemize}
|
|
|
|
\end{frame}
|
2020-04-16 19:40:17 +02:00
|
|
|
%------------------------------------------------
|
|
|
|
|
2020-04-20 11:40:16 +02:00
|
|
|
\begin{frame}[fragile]{Strukturen als Funktionsargument}
|
|
|
|
Ohne Typedef:
|
|
|
|
\begin{lstlisting}
|
|
|
|
void testfunc(struct Adresse a){
|
|
|
|
long plz = a.plz;
|
|
|
|
}
|
|
|
|
\end{lstlisting}
|
|
|
|
Mit Typedef:
|
|
|
|
\begin{lstlisting}
|
|
|
|
void testfunc(ADR a){
|
|
|
|
long plz = a.plz;
|
|
|
|
}
|
|
|
|
\end{lstlisting}
|
2020-04-16 19:40:17 +02:00
|
|
|
\end{frame}
|
|
|
|
|
|
|
|
%------------------------------------------------
|
|
|
|
|
2020-04-20 15:25:40 +02:00
|
|
|
\begin{frame}[fragile]{Strukturen in Java}
|
2020-04-16 19:40:17 +02:00
|
|
|
\begin{itemize}
|
|
|
|
\item existieren nicht
|
|
|
|
\item stattdessen Objekte
|
|
|
|
\end{itemize}
|
2020-04-20 15:25:40 +02:00
|
|
|
\begin{lstlisting}[language=java]
|
2020-04-22 10:20:51 +02:00
|
|
|
public class Adresse
|
2020-04-20 15:25:40 +02:00
|
|
|
{
|
|
|
|
String name;
|
|
|
|
String strasse;
|
|
|
|
short hausnummer;
|
|
|
|
long plz;
|
|
|
|
String stadt;
|
|
|
|
}
|
|
|
|
\end{lstlisting}
|
2020-04-16 19:40:17 +02:00
|
|
|
\end{frame}
|
|
|
|
|
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
% SECTION 2
|
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
|
2020-04-17 11:53:35 +02:00
|
|
|
|
2020-04-16 19:40:17 +02:00
|
|
|
\section{Pointer} % Section title slide, unnumbered
|
|
|
|
|
|
|
|
%------------------------------------------------
|
|
|
|
|
|
|
|
\begin{frame}{Grundlagen}
|
2020-04-20 15:25:40 +02:00
|
|
|
\begin{itemize}
|
|
|
|
\item Variable die Speicheradresse enthält
|
|
|
|
\item Pointer zeigt wo das Objekt zu finden ist.
|
|
|
|
\item nicht alle Pointer enthalten Adresse
|
|
|
|
\begin{itemize}
|
|
|
|
\item NULL-Pointer
|
|
|
|
\end{itemize}
|
|
|
|
\item * definiert einen Pointer
|
|
|
|
\item \& Wert eines Pointers
|
|
|
|
\end{itemize}
|
2020-04-16 19:40:17 +02:00
|
|
|
\end{frame}
|
|
|
|
|
|
|
|
%------------------------------------------------
|
|
|
|
|
2020-04-22 10:39:24 +02:00
|
|
|
\begin{frame}[fragile]{Pointer Syntax}
|
|
|
|
\begin{lstlisting}
|
|
|
|
#include <stdio.h>
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
//Variable declaration
|
|
|
|
int num = 10;
|
|
|
|
|
|
|
|
//Pointer declaration
|
|
|
|
int *p;
|
|
|
|
|
|
|
|
//Assigning address of num to the pointer p
|
|
|
|
p = #
|
|
|
|
|
|
|
|
printf("Address of variable num is: %p", p);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
\end{lstlisting}
|
2020-04-16 19:40:17 +02:00
|
|
|
\end{frame}
|
|
|
|
|
|
|
|
%------------------------------------------------
|
|
|
|
|
|
|
|
\begin{frame}[focus]
|
2020-04-22 10:20:51 +02:00
|
|
|
Danke für eure Aufmerksamkeit!
|
2020-04-16 19:40:17 +02:00
|
|
|
\end{frame}
|
|
|
|
|
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
% CLOSING/SUPPLEMENTARY SLIDES
|
|
|
|
%----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
\appendix
|
|
|
|
|
|
|
|
\begin{frame}{References}
|
|
|
|
\nocite{*} % Display all references regardless of if they were cited
|
2020-04-22 10:20:51 +02:00
|
|
|
\bibliography{quellen}
|
2020-04-16 19:40:17 +02:00
|
|
|
\bibliographystyle{plain}
|
|
|
|
\end{frame}
|
|
|
|
|
|
|
|
\end{document}
|