Upload
pranshu-jaiswal
View
217
Download
0
Embed Size (px)
Citation preview
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 1/19
Introduction to C++
COMP 322
1-Credit Hour
Junaed SattarSchool of Computer Science
&Center for Intelligent Machines
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 2/19
Some Course Facts
● 13 classes
● Third offering
● Commercially valuable language
● “Crash course” in C++
● Covering many aspects of the language
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 3/19
IMPORTANT
● NOT AN INTRODUCTORY PROGRAMMINGCOURSE
● MUST KNOW C or JAVA
● knowing C is great since C++ is a superset of C
● knowing Java is great too, since it's an OOPL
● IF NEITHER, AND NO PRE-REQS, MUST
NOT TAKE COURSE
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 4/19
More Course Facts
● Old website at● http://www.cim.mcgill.ca/~junaed/teaching/comp322/
● Official Course Management on WebCT
● Office hours: – Tuesdays, noon
● Academic Integrity:
– McGill University rules apply. See course outline.
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 5/19
Assessment?
● Two “short” midterms
– second midterm will NOT be comprehensive
● Three assignments
– approximately three weeks for each.
– MUST do in g++ (GNU C++ Compiler)
● “g++ program.cpp -o program -g2 -Wall”
– you can get g++ for all major operatingsystems
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 6/19
Observations
● One-credit != “easy”
● C++ != “easy”
– This is not easy grades
● me... no comments
– you'll figure out at the end of the semester :)
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 7/19
Course T.A.s
Grzegorz Prokopski,School of Computer Science
Yogesh Girdhar,School of Computer Science
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 8/19
What I do
● PhD at the School of Computer Science
● But, work at the Centre for Intelligent Machines, inmobile robotics
–
Computer Vision, Human-robot Interaction,Machine Learning
● Embedded Systems (Aqua underwater robots)
– Embedded programming, OS (Linux) creation
and configuration● Fully implemented research
– not just Matlab prototypes
–
C++ implemention exceeds 70+ KLOC
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 9/19
Now, to C++
● Used to be called “C with classes”
– And it was that, for a while.
● Inspired from C/Simula/Ada/Algol
● Compiled, general purpose, mid-level,multi-paradigm
– can do whatever you want to (gaming,
systems, embedded, database...) – Higher than C, lower than Java
– May or may not be object-oriented (unlike Java)
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 10/19
Features
● Created to address problems of C; like,
● No code reusability
● minimalistic
●
basic support only for modular programming● basic support only for generic programming
● no OOP support (and hence OOP features)
● no native multithreading, networking support
●
and so on and so forth
● C++ does not address all of these,however
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 11/19
Features
● But it does provide OOP support
● arguably most complete, most complex, mostpowerful OOP support
●
multiple inheritance, template metaprogramming,function and operator overloading, type-ID, run-time function call binding
● Code reusability, data protection, modularity
– Enhance memory allocation/deallocationschemes
– Strongly typed
● Enhanced type casting
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 12/19
Missing elements
● C++ still is missing
– native threads, yet
– native GUI library
– native neworking toolset
● That said, loads of “quality” open-sourceand commercial libraries available.
– Boost, GTKmm, QT, MFC, Windows Forms etc.
● Design of the language facilitates such“pluggable” libraries
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 13/19
Criticisms
● “Too (your favorite swear-word here) big”.
● Feature-bloat?
● notoriously difficult to learn and use
– “...design allows developers to make seriousprogramming mistakes in the interest of preserving their freedom.”
●
Look at this. From the creator himself. – http://www.technologyreview.com/Infotech/17
831/?a=f
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 14/19
Quotes
● Bjarne Stroustrup, on C:
– “C makes it easy to shoot yourself in thefoot.”
●
An astute reader/programmer/not a C++fanboy:
– “... though C++ makes it harder, when youdo shoot yourself in the foot, it blows yourwhole leg off.”
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 15/19
The STL
● Stands for the “Standard templatelibrary”
● Most C++ programmers “underutilize”
this excellent resource● Must be proficient with the STL to use C+
+ well.
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 16/19
STL provides...
● containers, iterators, algorithms, andfunctors
– containers like vectors, lists, dynamic arrays
– iterators for sequentially accessing thesecontainers
– algorithms for searching, sorting and more
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 17/19
The C++ Standard
● Standardized C++ in 1998
● Corrected in 2003
● TR1 (Technical report 1) published in 2005
– Not a part of the standard, yet, but containsproposals for extensions, that has a highprobability of making it to the next standard
– most compilers are working on supportingthe full standard as well as TR1
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 18/19
Coding points
● Compilers are still catching up to thestandard
● The standard is also evolving
● Use recent compilers
– G++ 4.x.x, or the recent Visual C++ (can'ttell you which version, sorry)
●
Use of IDE's are not at all necessary fornow
– Might be useful for large projects
8/4/2019 comp322_01
http://slidepdf.com/reader/full/comp32201 19/19
Next Class
● Starting out with C++