\documentclass{beamer}
\usepackage{verbatim}
\usepackage[english]{babel}


\usepackage{lmodern}
\usepackage{listings}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\usepackage{textcomp}
\usepackage{xcolor,colortbl}
\usepackage[utf8]{inputenc}
\usepackage{flexisym}
\usepackage{comment}
\newcommand{\apostrophe}{{\quotefont\textquotesingle}} % or just use {\quotefont text}

\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}

\newcolumntype{a}{>{\columncolor{Gray}}c}
\newcolumntype{b}{>{\columncolor{white}}c}

\newenvironment<>{varblock}[2][.9\textwidth]{%
  \setlength{\textwidth}{#1}
  \begin{actionenv}#3%
    \def\insertblocktitle{#2}%
    \par%
    \usebeamertemplate{block begin}}
  {\par%
    \usebeamertemplate{block end}%
  \end{actionenv}}
	
\usetheme{Frankfurt}
\usepackage{movie15}
\title{programming in C++}
\author{Jonas Vejlin}
\date{}

\begin{document}


\maketitle

\begin{frame}
\frametitle{Parts}

\begin{block}{Part 1}
Basic programming
\end{block}
\begin{block}{Part 2}
Control structure such as loops and if-else 
\end{block}
\begin{block}{Part 3}
Vector, Functions and Input/Ouput (Today)
\end{block}
\end{frame}
\section{Files}
\begin{frame}
\frametitle{Agenda}

 \frametitle{Table of Contents}
\tableofcontents[currentsection,hideallsubsections]

\end{frame}
\subsection{Write File}
\begin{frame}
\frametitle{Write File}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include <iostream>\newline
\alert<1>{\#include <fstream>}\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<2>{\hspace*{2em}ofstream myfile;}}\newline
{\alert<3>{\hspace*{2em}myfile.open ("C:\\\\example.txt");}}\newline
{\alert<4>{\hspace*{2em}myfile$<<$1$<<$\textquotesingle\\t\textquotesingle$<<$ 2$<<$endl;}}\newline
{\alert<5>{\hspace*{2em}myfile$<<$3$<<$\textquotesingle\\t\textquotesingle$<<$ 4$<<$endl;}}\newline
{\alert<6>{\hspace*{2em}myfile.close();}}\newline
	cin.get();\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{File}
\alt<1-3>{ \hspace*{2em}\newline}{\alert<4>{1 \hspace*{2em} 2}\newline}
\alt<1-4>{ \hspace*{2em} \newline}{\alert<5>{3 \hspace*{2em} 4}\newline}
\end{varblock}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}



\end{varblock}
\end{column}
\end{columns}
\end{frame}

\subsection{Read File}
\begin{frame}
\frametitle{Read File}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include <iostream>\newline
\alert<1>{\#include <fstream>}\newline
\alert<1>{\#include <string>}\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<2>{\hspace*{2em}ifstream \alert<5>{myfile};}}\newline
{\alert<3>{\hspace*{2em}myfile.open ("C:\\\\example.txt");}}\newline
{\alert<4>{\hspace*{2em}string \alert<6>{line};}}\newline
{					{\hspace*{2em}while(\alert<9>{\alert<7>{getline(\alert<5>{myfile},\alert<6>{line}))}}}}\newline
{					{\hspace*{2em}\{}}\newline
\alert<10>{\alert<8>{\hspace*{2em}cout$<<$line$<<$endl;}}\newline
{					{\hspace*{2em}\}}}\newline
{\alert<11>{\hspace*{2em}myfile.close();}}\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}
\alt<1-7>{ \hspace*{2em}\newline}{\alert<8>{1 \hspace*{2em} 2}\newline}
\alt<1-9>{ \hspace*{2em} \newline}{\alert<10>{3 \hspace*{2em} 4}\newline}
\end{varblock}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}
\alt<1-5>{ \hspace*{2em}\newline}{\alt<6-6>{{\alert<6>{line}}\newline}{\alt<7-8>{\alert<7>{line= 1 \hspace*{2em} 2}}{\alert<9>{line= 3 \hspace*{2em} 4}}}}


\end{varblock}
\end{column}
\end{columns}
\end{frame}

\subsection{Splitting of a string}
\begin{frame}
\frametitle{Splitting of a string}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6.35cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include <iostream>\newline
\alert<1>{\#include <sstream>}\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<2>{\hspace*{2em}string line="56.5,54.32";}}\newline
{\alert<3>{\hspace*{2em}string \alert<6>{ token};}}\newline
{\alert<4>{\hspace*{2em}stringstream \alert<5>{ss}(line);}}\newline
{					{\hspace*{2em}while(\alert<11>{\alert<8>{getline(\alert<5>{ss}, \alert<6>{token},\alert<7>{\textquotesingle,\textquotesingle }))}}}}\newline
{					{\hspace*{2em}\{}}\newline
								{\alert<12>{\alert<10>{double info=\alert<9>{atof(token.c_str());}}}}\newline
{					{\hspace*{2em}\}}}\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}

\end{varblock}

\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}
\alt<1-1>{ \hspace*{2em}\newline}{\alert<2>{line="56.5,54.32"}\newline}
\alt<1-2>{ \hspace*{2em}\newline}{\alt<3-7>{\alert<3>{token}}{\alt<8-10>{\alert<8>{token=56.5}}{\alert<11>{token=54.32}}}\newline}
\alt<1-9>{ \hspace*{2em}\newline}{\alt<10-11>{\alert<10>{info=56.5}}{\alert<12>{info=54.32}}}
\end{varblock}
\end{column}
\end{columns}
\end{frame}
\section{Vector}
\begin{frame}
\frametitle{Agenda}

 \frametitle{Table of Contents}
\tableofcontents[currentsection,hideallsubsections]

\end{frame}

\subsection{Graphical Representation}
\begin{frame}
\frametitle{Graphical Representation}
\begin{center}
\includegraphics<1>[width=.60\textwidth]{array.png}
\end{center}
\end{frame}

\subsection{Vector example}

\begin{frame}
\frametitle{Vector example}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include <iostream>\newline
\#include <vector>\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<1>{\hspace*{2em}vector<int> MyList(2)}}\newline
{\alert<2>{\hspace*{2em} MyList[0]=1;}}\newline
{\alert<3>{\hspace*{2em} MyList[1]=2;}}\newline
{\alert<4>{\hspace*{2em}  MyList.push_back(5);}}\newline
{\alert<5>{\hspace*{2em} cout$<<$MyList[0]$<<$endl;}}\newline
{\alert<6>{\hspace*{2em} cout$<<$MyList[1]$<<$endl;}}\newline
{\alert<7>{\hspace*{2em} cout$<<$MyList[2]$<<$endl;}}\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}

\alt<1-4>{ \hspace*{2em} \newline}{\alert<5>{1}\newline}
\alt<1-5>{ \hspace*{2em} \newline}{\alert<6>{2}\newline}
\alt<1-6>{ \hspace*{2em} \newline}{\alert<7>{5}\newline}
\end{varblock}

\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}
\alt<1-1>{ \alert<1>{array1[0]=0}}{\alert<2>{array1[0]=1}\newline}
\alt<1-2>{ \alert<1>{array1[1]=0}}{\alert<3>{array1[1]=2}\newline}
\alt<0-3>{ \hspace*{2em}\newline}{\alert<4>{array1[2]=5}\newline}

\end{varblock}
\end{column}
\end{columns}
\end{frame}



\begin{frame}
\frametitle{loops and vector example}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6.7cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include <iostream>\newline
\alert<1>{\#include <vector>}\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<2>{\hspace*{2em}vector<double> MyList(2);}}\newline
{\alert<3>{\hspace*{2em}MyList[0]=1.2;}}\newline
{\alert<4>{\hspace*{2em}MyList[1]=2.2;}}\newline
{{for(\alert<5>{int i=0};{\alert<12>{\alert<9>{\alert<6>{i<MyList.size()}}}};{\alert<11>{\alert<8>{i=i+1)}}}}}\newline
{					{\hspace*{2em}\{}}\newline
{\alert<10>{\alert<7>{\hspace*{2em}{cout$<<$"the value is " $<<$MyList[i]$<<$endl;}}}}\newline
{					{\hspace*{2em}\}}}\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}
\alt<1-6>{ \hspace*{2em} \newline}{\alert<7>{the value is 1.2}\newline}
\alt<1-9>{ \hspace*{2em} \newline}{\alert<10>{the value is 2.2}\newline}

\end{varblock}

\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}
\alt<0-1>{ \hspace*{2em}\newline}{\alt<2>{\alert<2>{MyList[0]=0}}{\alert<3>{MyList[0]=1.2}}\newline}
\alt<0-1>{ \hspace*{2em}\newline}{\alt<2-3>{\alert<2>{MyList[1]=0}}{\alert<4>{MyList[0]=2.2}}\newline}

\alt<1-4>{ \hspace*{2em}\newline}{\alt<5-7>{\alert<5>{i=0}}{\alt<8-10>{\alert<8>{i=1}}{\alt<11-13>{\alert<11>{i=2}}{\alert<15>{i=3}}}}}\newline
\end{varblock}
\end{column}
\end{columns}
\end{frame}
\section{Functions}
\subsection{Intro to functions}
\begin{frame}
\frametitle{Intro to functions}
\begin{itemize}
\item Function description (done in the header (.h) file)
\item Function implementation (done in the c++ (.cpp) file)
\item Calling the function 
\end{itemize}
\end{frame}
\subsection{header file (.h-file)}
\begin{frame}

\frametitle{header file (.h-file)}
\begin{varblock}[6.7cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\alert<3> {double} \alert<1>{mean}(\alert<2> {double a}, \alert<2>{ double b});
\end{semiverbatim} 
\end{varblock}
\end{frame}
\subsection{body file (.cpp-file)}
\begin{frame}

\frametitle{body file (.cpp-file)}
\begin{varblock}[6.7cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\alert<5> {double} mean(double \alert<2> {a},  double \alert<2> {b})
\alert<1>{\{}
\hspace*{2em}\newline \alert<3> {double value=(\alert<2> {a}+\alert<2> {b})};
\hspace*{2em}\newline \alert<4> {return value};
\alert<1>{\}}
\end{semiverbatim} 
\end{varblock}
\end{frame}
\subsection{Using the function}
\begin{frame}

\frametitle{Using the function}
\begin{varblock}[6.7cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include <iostream>\newline
\alert<1>{"function1.h"}\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<4>{double result }=\alert<2>{mean}(\alert<3>2,\alert<3>2);}\newline

\}
\end{semiverbatim} 
\end{varblock}
\end{frame}
\end{document}