Upload
avis-moody
View
213
Download
0
Embed Size (px)
Citation preview
Introduction to C++
Shirley Moorehttp://www.cs.utep.edu/svmoore/
[email protected] 5401, Fall 2013
http://svmoore.pbworks.com/
History of C++• Reference: www.cplusplus.com/ • History going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis• Stroustrup was working with the Simula 67 language, regarded as the first language to
support the object-oriented programming paradigm, but it was too slow to be of practical use.
• Goal was to add object-oriented programming into the C language without sacrificing speed or low-level functionality.
• His language included classes, basic inheritance, inlining, default function arguments, and strong type checking in addition to all the features of the C language.
• In 1983, the name of the language was changed from C with Classes to C++. New features included virtual functions and function overloading.
• In 1985, Stroustrup’s The C++ Programming Language was published. Also in 1985, C++ was implemented as a commercial product.
• In 1990, The Annotated C++ Reference Manual was pubslished and Borland's Turbo C++ compiler was released as a commercial product.
• In 1998, the C++ standards committee published the first international standard for C++ ISO/IEC 14882:1998, informally known as C++98.
• In mid-2011, the new C++ standard (dubbed C++11) was finished. New features included a standard threading library.
Features of C++• C++ ...is an open ISO-standardized language.
...is a compiled language.
...is a strongly-typed unsafe language.
...supports both manifest and inferred typing.
...supports both static and dynamic type checking.
...offers many paradigm choices.
...is portable.
...is upwards compatible with C.
...has vast library support.
Classes
• Object-oriented programming concept• A class is a construct that is used to create instances
of itself – referred to as class instances or objects• A class defines members that enable its instances to
have state and behavior.– Data field members (member variables or instance
variables) enable a class instance to maintain state.– Methods enable the behavior of class instances.
• Classes support information encapsulation.• Classes define the type of their instances.
Inheritance
• Inheritance is a mechanism of reusing and extending existing classes, thus producing hierarchical relationships between them.
• A new class is derived from the base class.– Can add new data members and member functions to the
derived class. – Can modify the implementation of existing member
functions or data by overriding base class member functions or data in the newly derived class.
• Multiple inheritance allows you to create a derived class that inherits properties from more than one base class.
Polymorphic Functioins
• Polymorphic functions are functions that can be applied to objects of more than one type. In C++, polymorphic functions are implemented in two ways: – Overloaded functions are statically bound at
compile time.– A virtual function is a function that can be called for
a number of different user-defined types that are related through derivation. Virtual functions are bound dynamically at run time.
HPC Codes Written in C++
• MPQC computational chemistry code– www.mpqc.org
• C++ development version of GAMESS• LAMMPS molecular dynamics code
– lammps.sandia.gov• NAMD molecular dynamics code
– www.ks.uiuc.edu/Research/namd/• Object-oriented math libraries (parts written in Fortran and/or C
and/or using code generators)– PETSc– Trilinos
• Many others