Hydroinformatik I: Hello World Prof. Dr.-Ing. habil. Olaf Kolditz 1 Helmholtz Centre for Environmental Research UFZ, Leipzig 2 Technische Universität Dresden TUD, Dresden Dresden, 27. Oktober 2017 1/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Time Table 2/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
IDEs, Compiler... Which one... ECLIPSE Visual Studio Community (MS) https: //tutorials.visualstudio.com/cpp-console/intro Qt (https://www.qt.io/download/) cygwin (https://www.cygwin.com/) MinGW (http://www.mingw.org/) MinGW, a contraction of Minimalist GNU for Windows, is a minimalist development environment for native Microsoft Windows applications. GNU GNU is a recursive acronym for GNU s Not Unix! https://en.wikipedia.org/wiki/gnu XCode... 3/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
IDEs, Compiler... Which one... Wer hat welchen Compiler? Win Mac Linux Ubuntu... Compiler 2017 4/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Übungen Download 5/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Compiler - How it works Editor Source file Header file Compiler Object file Linker Libraries Executable Abbildung: Quell-Code Kompilation 6/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Hello World Skript 1.4, Übung E1 C #include <stdio.h> int main() { printf("hallo C world\n"); return 0; } C++ #include <iostream> //using namespace std; int main() { std::cout << "Hallo C++ World, wirklich?" << std::endl; return 0; } 7/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Main-Function function type function name function arguments function start function end int main() {... return 0; } function block Abbildung: Struktur der Funktion main() 8/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Exercise E1 Abbildung: cygwin aufrufen Abbildung: cygwin drive ist /cygwin/home/user, wechseln zum Arbeitsverzeichnis cd c:/myworkdirectory (oder copy und paste) Abbildung: slash (/) ist nicht gleich slash (\) 9/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Exercise E1A Die einzige C Übung: #include <stdio.h> int main() { printf("hello World"); return 0; } 10/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Exercise E1A Abbildung: Kommandozeile: gcc main.c, das Ergebnis ist a.exe, Aufruf des Programms:./a Jetzt endlich zu C++... 11/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Exercise E1A Jetzt aber endlich zu C++... #include <iostream> using namespace std; int main() { cout << "Hello World" << endl; return 0; } 12/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Exercise E1A Abbildung: Kommandozeile: g++ main.cpp, mit ls den Inhalt des Verzeichnisses ansehen, das Ergebnis ist a.exe, Aufruf des Programms:./a 13/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
C und/oder C++ Exercise E1C (oder HW2) Compilieren sie den Quelltext main.c mit dem C Compiler gcc. Compilieren sie den Quelltext main.cpp mit dem C++ Compiler g++. Compilieren sie den Quelltext main.c mit dem C++ Compiler g++. Compilieren sie den Quelltext main.cpp mit dem C Compiler gcc. KF 14/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Objekt-Orientierung Historical Note 15/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Objekt-Orientierung Historical Note 1983: Bjarne Stroustroup at ATT Lab Inspirations: C++ owes much to C (Kernighan 1978) Simula67 (Dahl 1972) class concept virtual functions Algol68 (Woodwad 1974) overloading operators declarations in header files Template facilities (list, vector, map container) Name C++: signifies the evolutionary nature of the changes from C ( ++ is the increment operator) 1991: C++ became ANSI and ISO standards 16/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Objekt-Orientierung 17/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Objekt-Orientierung 18/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Objekt-Orientierung 19/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Visual C++ (appetizer) Abbildung: Grafischer Dialog - Hydroinformatik I* (-2012) 20/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++
Visual C++ (appetizer) Abbildung: Grafischer Dialog - Hydroinformatik II 21/21 Prof. Dr.-Ing. habil. Olaf Kolditz Hydroinformatik I C++