Download presentation
Presentation is loading. Please wait.
1
Basic C++ lectures 1 and 2MSc Bioinformatics Basic C++ daniel.soto@upf.edu
2
Basic C++ lectures 1 and 2MSc Bioinformatics Introduction Daniel Soto e-mail:daniel.soto@upf.edu phone:93 542 2634 address:Departament de Tecnologia Desp.374 Estació de França Passeig de Circumval·lació, 8 08003 Barcelona
3
Basic C++ lectures 1 and 2MSc Bioinformatics Introduction Philosophy: learn to program with objects Bibliography The C++ Programming Language, 3rd Edition by Bjarne Stroustrup. Addison Wesley Professional. http://www.awprofessional.com/title/0201889544 http://www.awprofessional.com/title/0201889544 “Aprenda C++ como si estuviera en primero” http://mat21.etsii.upm.es/ayudainf/aprendainf/Cpp/ manualcpp.pdf
4
Basic C++ lectures 1 and 2MSc Bioinformatics Programming Languages Machine Languages Assembly Languages High-Level Languages +1300042774 +1400593419 +1200274027 LOAD A ADD B STORE C C=A+B
5
Basic C++ lectures 1 and 2MSc Bioinformatics Programming paradigms Imperative Declarative Functional Object-Oriented
6
Basic C++ lectures 1 and 2MSc Bioinformatics Evolution of High-Level Programming Languages Functions and Methods Libraries (packages, units, etc.) Abstract Data Types Objects
7
Basic C++ lectures 1 and 2MSc Bioinformatics C++ language History 1980, creation of different flavours of “C with Classes” 1983, C++ evolution from C with inspiration in Simula67 1991, ANSI C++ C++ vs. C C was chosen as the base language for C++ because it: is versatile, terse, and relatively low-level; is adequate for most systems programming tasks; runs everywhere and on everything; and fits into the UNIX programming environment.
8
Basic C++ lectures 1 and 2MSc Bioinformatics C++ language What is C++? C++ is a general-purpose programming language with a bias towards systems programming that: is a better C, supports data abstraction, supports object-oriented programming, and supports generic programming. C is retained as a subset inside C++ (this is not completely true!)
9
Basic C++ lectures 1 and 2MSc Bioinformatics C++ language First program (C-style): #include int main() { printf("Hello world!\n"); } ; First program (Pure C++-style): #include int main() { std::cout << "Hello world!\n"; } ;
10
Basic C++ lectures 1 and 2MSc Bioinformatics Compilation hello.o compile a.out a.exe hello.cpp C++ runtime Link Source FileObject FileExecutable Edit g++ hello.cpp
11
Basic C++ lectures 1 and 2MSc Bioinformatics C/C++ Compatibility General: C++ provides the // comments // a comment return a; // another comment C Code that is not C++: Functions in C++ have strict syntax main() {} // Valid in C, not valid in C++ int main() {;} // Valid in C++ Default types not assumed const a=7; // In C is type int, not in C++ Several new keywords in C++: class, this, throw, public, protected, private, virtual, true, false, template, inline, friend, new …
12
Basic C++ lectures 1 and 2MSc Bioinformatics Summary C++ is a evolution of C. We can continue to use C syntax. Formal variations exist. We need to use a different compiler and new file extension. A new programming paradigm is integrated into it.
13
Basic C++ lectures 1 and 2MSc Bioinformatics Summary The paradigm of Object-Oriented Programming
14
Basic C++ lectures 1 and 2MSc Bioinformatics OOP: Objective Say to a machine what it need to do (using objects). In general this is programming
15
Basic C++ lectures 1 and 2MSc Bioinformatics OOP: approach We can view a program as a “object” This object is the medium to do work using a machine A
16
Basic C++ lectures 1 and 2MSc Bioinformatics OOP: approach Is the Object-Oriented Programming a thing like… Cooking programs with objects?
17
Basic C++ lectures 1 and 2MSc Bioinformatics OOP: approach Create programs with pieces? Work with programs?
18
Basic C++ lectures 1 and 2MSc Bioinformatics OOP: concepts Object: a mix of data and procedures Abstraction: view only a partial view of a thing Message interchange: how to object delegates a task to other object Class: the model of the object Instance: one agent (the object) Heritage: How to an object is a “derivate” from another object Polymorphism: Different views of the same object
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.