einige Rechtschreibfehler ausgebessert
verschoenerungen
This commit is contained in:
parent
8fe919bb9a
commit
ee48380e0a
107
src/main.tex
107
src/main.tex
@ -3,7 +3,7 @@
|
|||||||
% Struktur und Pointer Referat
|
% Struktur und Pointer Referat
|
||||||
% 20.04.2020
|
% 20.04.2020
|
||||||
%----------------------------------------------------------------------------------------
|
%----------------------------------------------------------------------------------------
|
||||||
\usetheme{focus} % Use the Focus theme supplied with the template
|
\usetheme{focus}
|
||||||
|
|
||||||
\usepackage[utf8]{inputenc}
|
\usepackage[utf8]{inputenc}
|
||||||
|
|
||||||
@ -11,7 +11,7 @@
|
|||||||
\usepackage{amsmath}
|
\usepackage{amsmath}
|
||||||
\usepackage{hyperref}
|
\usepackage{hyperref}
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
\usepackage{listings} % Required for better table rules
|
\usepackage{listings}
|
||||||
\usepackage{xcolor}
|
\usepackage{xcolor}
|
||||||
|
|
||||||
% Farbdefinitionen
|
% Farbdefinitionen
|
||||||
@ -51,14 +51,12 @@
|
|||||||
% TITLE SLIDE
|
% TITLE SLIDE
|
||||||
%----------------------------------------------------------------------------------------
|
%----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
\title{Strukturen + Pointer \\ Call by Reference/Value}
|
\title{Strukturen + Pointer}
|
||||||
|
|
||||||
\subtitle{mit Anwendungsfälle / Programmierbeispiele}
|
\subtitle{mit Anwendungsfälle / Programmierbeispiele}
|
||||||
|
|
||||||
\author{Lukas Heiligenbrunner}
|
\author{Lukas Heiligenbrunner}
|
||||||
|
|
||||||
\institute{HTL Steyr \\ Schlüsselhofgasse 63}
|
|
||||||
|
|
||||||
\date{\today}
|
\date{\today}
|
||||||
|
|
||||||
%------------------------------------------------
|
%------------------------------------------------
|
||||||
@ -68,7 +66,7 @@
|
|||||||
%------------------------------------------------
|
%------------------------------------------------
|
||||||
|
|
||||||
\begin{frame}
|
\begin{frame}
|
||||||
\maketitle % Automatically created using the information in the commands above
|
\maketitle
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
%----------------------------------------------------------------------------------------
|
%----------------------------------------------------------------------------------------
|
||||||
@ -88,12 +86,16 @@
|
|||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item NULL-Pointer
|
\item NULL-Pointer
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
\pause
|
||||||
\item Operator *
|
\item Operator *
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item definiert einen Pointer
|
\item definiert einen Pointer
|
||||||
\item Wert eines Pointers
|
\item Wert eines Pointers
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\item \& Operator: Adresse einer Variable
|
\item Operator \&
|
||||||
|
\begin{itemize}
|
||||||
|
\item Adresse einer Variable
|
||||||
|
\end{itemize}
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
@ -104,16 +106,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
//Variable declaration
|
// Variable definieren
|
||||||
int num = 10;
|
int num = 10;
|
||||||
|
|
||||||
//Pointer declaration
|
// Pointer definieren
|
||||||
int *p;
|
int *p;
|
||||||
|
|
||||||
//Assigning address of num to the pointer p
|
// Adresse von num --> p zuweisen
|
||||||
p = *num;
|
p = #
|
||||||
|
|
||||||
printf("Num: %d", &p);
|
printf("Num: %d", *p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
@ -124,7 +126,7 @@ int main()
|
|||||||
\begin{frame}{Pointer in Java}
|
\begin{frame}{Pointer in Java}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item Alle Objekte automatisch Pointer
|
\item Alle Objekte automatisch Pointer
|
||||||
\item Primitives (int, float, double) sind Wert direkt
|
\item Primitives (int, float, double) keine Pointer
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ int main()
|
|||||||
\item Keyword \textit{struct}
|
\item Keyword \textit{struct}
|
||||||
\pause
|
\pause
|
||||||
\item verbessert Übersicht
|
\item verbessert Übersicht
|
||||||
\item Schritt richtung Objektorientierung
|
\item Schritt Richtung Objektorientierung
|
||||||
\item ideal für Listen und Baumstruktur
|
\item ideal für Listen und Baumstruktur
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
@ -179,25 +181,38 @@ adresseKurt.plz = 45678;\end{lstlisting}
|
|||||||
|
|
||||||
Typdefinition mit typedef:
|
Typdefinition mit typedef:
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
|
struct Adresse {
|
||||||
|
char name[50];
|
||||||
|
short hausnummer;
|
||||||
|
};
|
||||||
|
typedef struct Adresse Adr;
|
||||||
|
|
||||||
|
Adr a1,a2; // Datentyp Adr
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
|
Kombination:
|
||||||
|
\begin{lstlisting}
|
||||||
typedef struct Adresse {
|
typedef struct Adresse {
|
||||||
char name[50];
|
char name[50];
|
||||||
short hausnummer;
|
short hausnummer;
|
||||||
} ADR;
|
} Adr;
|
||||||
|
|
||||||
ADR a1,a2;
|
Adr a1,a2; // Datentyp Adr
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
\begin{frame}{Sonstiges}
|
\begin{frame}{Sonstiges}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item Strukturtypdeklaration: struct Adresse \{…\};
|
\item Strukturtypdeklaration: struct Adresse \{…\};
|
||||||
\item Gesamtlänge der Struktur: sizeof(Struktur)
|
|
||||||
\item Zugriff auf einzelne Komponenten durch\\
|
\item Zugriff auf einzelne Komponenten durch\\
|
||||||
Punktnotation: Adresse1.Vorname = “Peter“;
|
Punktnotation: (Adresse1.Vorname = “Peter“);
|
||||||
\item Pfeilnotation (->) wenn struct ist Pointer
|
\pause
|
||||||
|
\item Pfeilnotation (->) wenn struct Pointer
|
||||||
|
\item Gesamtlänge der Struktur: sizeof(Struktur)
|
||||||
\item Weiteres hinzufügen von Komponenten während der Laufzeit nicht möglich.
|
\item Weiteres hinzufügen von Komponenten während der Laufzeit nicht möglich.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
%------------------------------------------------
|
%------------------------------------------------
|
||||||
|
|
||||||
\begin{frame}[fragile]{Strukturen als Funktionsargument}
|
\begin{frame}[fragile]{Strukturen als Funktionsargument}
|
||||||
@ -209,7 +224,7 @@ void testfunc(struct Adresse a){
|
|||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
Mit Typedef:
|
Mit Typedef:
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
void testfunc(ADR a){
|
void testfunc(Adr a){
|
||||||
long plz = a.plz;
|
long plz = a.plz;
|
||||||
}
|
}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
@ -220,7 +235,7 @@ void testfunc(ADR a){
|
|||||||
\begin{frame}[fragile]{Strukturen in Java}
|
\begin{frame}[fragile]{Strukturen in Java}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item existieren nicht
|
\item existieren nicht
|
||||||
\item stattdessen Objekte
|
\item stattdessen Klassen
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\begin{lstlisting}[language=java]
|
\begin{lstlisting}[language=java]
|
||||||
public class Adresse
|
public class Adresse
|
||||||
@ -243,47 +258,47 @@ public class Adresse
|
|||||||
|
|
||||||
%------------------------------------------------
|
%------------------------------------------------
|
||||||
|
|
||||||
\begin{frame}[fragile]{Verkettete Listen}
|
\begin{frame}[fragile]{Struktur als Pointer}
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
struct node {
|
struct mystruct {
|
||||||
int data;
|
int data;
|
||||||
struct node* next;
|
|
||||||
};
|
};
|
||||||
typedef struct node node;
|
typedef struct MyStruct MyStruct;
|
||||||
|
|
||||||
void beispiel() {
|
void beispiel(MyStruct * str) {
|
||||||
// Erstellen von root
|
int d = str->data;
|
||||||
node *root = malloc(sizeof(node));
|
}
|
||||||
|
|
||||||
root->data = 17;
|
int main(){
|
||||||
|
MyStruct struc;
|
||||||
|
struc.data = 5;
|
||||||
|
beispiel(&struc);
|
||||||
|
|
||||||
// Anhaengen eines Knotens
|
return 0;
|
||||||
node *secondNode = malloc(sizeof(node));
|
|
||||||
root->next = secondNode;
|
|
||||||
secondNode->data = 19;
|
|
||||||
}
|
}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
%------------------------------------------------
|
%------------------------------------------------
|
||||||
|
|
||||||
\begin{frame}[fragile]{Struktur als Pointer}
|
\begin{frame}[fragile]{Verkettete Listen}
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
struct mystruct {
|
struct Node {
|
||||||
int data;
|
int data;
|
||||||
|
struct node* next;
|
||||||
};
|
};
|
||||||
typedef struct mystruct mystruct;
|
typedef struct Node Node;
|
||||||
|
|
||||||
void beispiel(mystruct * str) {
|
void beispiel() {
|
||||||
int d = str->data;
|
// Erstellen von root
|
||||||
}
|
Node *root = malloc(sizeof(Node));
|
||||||
|
|
||||||
int main(){
|
root->data = 17;
|
||||||
mystruct struc;
|
|
||||||
struc.data = 5;
|
|
||||||
beispiel(&struc);
|
|
||||||
|
|
||||||
return 0;
|
// Anhaengen eines Knotens
|
||||||
|
Node *secondNode = malloc(sizeof(Node));
|
||||||
|
root->next = secondNode;
|
||||||
|
secondNode->data = 19;
|
||||||
}
|
}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
Loading…
Reference in New Issue
Block a user