ebook img

Introduction to C++ (and C) Programming PDF

350 Pages·1999·7.39 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Introduction to C++ (and C) Programming

Intro Classes E(cid:14)ciency OOP Introduction to C++ (and C) Programming Hans Petter Langtangen1;2 SimulaResearchLaboratory1 Dept.ofInformatics,Univ.ofOslo2 January 2006 H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP Outline 1 Intro to C++ programming About C and C++ Introductory C++ example Manipulate data (cid:12)les Matrix-vector product The C preprocessor Exercises About classes in C++ A simple class 2 Class programming Class Complex A vector class Standard Template Library 3 E(cid:14)ciency; C++ vs. F77 4 Object-Oriented Numerical Programming OOP example: ODE solvers Classes for PDEs H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP Contents Gentle introduction to C++ File I/O Arrays and loops Detailed explanation of classes with built-in arithmetics Computational e(cid:14)ciency aspects Object-oriented programming and class hierarchies Using C++ objects in numerical applications H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP Required background Programming experience with either Java or Fortran/Matlab Interest in numerical computing with C++ Interest in low-level details of the computer Knowledge of some C is advantageous (but not required) H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP About learning C++ C++ is a complicated computer language It takes time to master C++ { one year is the rule of thumb Four days can only give a taste of C++ You need to work intensively with C++ in your own projects to master the language C++ exposes you to lots of \low-level details" { these are hidden in languages like Java, Matlab and Python Hopefully, you will appreciate the speed and (cid:13)exibility of C++ H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP Teaching philosophy Intensive course: Lectures 9-12 Hands-on training 13-16 Learn from dissecting examples Get in touch with the dirty work Get some overview of advanced topics Focus on principles and generic strategies Continued learning on individual basis This course just gets you started - use textbooks, reference manuals and software examples from the Internet for futher work with projects H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP Recommended attitude Dive into executable examples Don’t try to understand everything Try to adapt examples to new problems Look up technical details in manuals/textbooks Learn on demand Stay cool H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP C/C++ HelloWorld I/O A*x Macros Exercises Classes Simpleclass Why do you need to learn \old" compiled languages? Because C, C++, and Fortran (77/95) are the most e(cid:14)cient existing tools for intensive numerical computing Because tons of fast and well-tested codes are available in Fortran, C/C++ Newer languages have emphasized simplicity and reliability { at the cost of computational e(cid:14)ciency To get speed, you need to dive into the details of compiled languages, and this course is a (cid:12)rst, gentle step H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP C/C++ HelloWorld I/O A*x Macros Exercises Classes Simpleclass C C is a dominating language in Unix and Windows environments The C syntax has inspired lots of popular languages (Awk, C++, Java, Perl, Python, Ruby) Numerous tools (numerical libraries, e.g., MPI) are written in C; interfacing them requires C knowledge C is extremely portable; \all" machines can compile and run C programs C is very low level and close to the machine Unlimited possibilities; one can do anything in C Programmers of high-level languages often get confused by strange/unexpected errors in C H.P.Langtangen IntroductiontoC++(andC)Programming Intro Classes E(cid:14)ciency OOP C/C++ HelloWorld I/O A*x Macros Exercises Classes Simpleclass C++ C++ extends C with nicer syntax: - declare variables wherever you want - in/out function arguments use references (instead of pointers) classes for implementing user-de(cid:12)ned data types a standard library (STL) for frequently used data types (list, stack, queue, vector, hash, string, complex, ...) object-oriented programming generic programming, i.e., parameterization of variable types via templates exceptions for error handling C is a subset of C++ H.P.Langtangen IntroductiontoC++(andC)Programming

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.