Status History of Putting Up C++ Programming Course Content

The sections below deal with the status of putting up course content on this blog over the past few months.

Status around August 2013

I have written to Pearson Education India seeking permission from them for putting up those of the slides that have examples and maybe some other material from the course book. I hope to receive their permission as the slides will be promoting their book. Students interested in seriously using the slides and other course content here would need to buy/refer the book for details. Such a purchase would usually stand students in good stead even after going through this course as the book can be a companion or reference for future work involving C++ like an M.Tech. (CS) project or even initial period of software industry programming career.

Status update on 10th February 2014

In August 2013 I had interacted with the appropriate person of Pearson Education India, Rights and Permissions department (http://www.pearsoned.co.in/web/Rights.aspx), over email and telephone which resulted in me sending them (by email) a zip file on 21st August 2013 with my C++ programming course slides. I have copy-pasted the main body of the mail below:

Further to our telephone discussion today afternoon please find attached a zip file which has all the C++ course slides, that I intend to put up on my site here: https://raviiyerteaches.wordpress.com/2013/08/15/cpp-programming/. As the book, C++ Primer, 4th edition by authors Lippman, Lajoie and Moo, http://www.pearsoned.co.in/prc/book/stanley-b-lippman-c-primer-4e–4/9788131710777, is the course book for the C++ course mentioned above, many of the slides refer to examples and sections of the book.

I seek permission from Pearson Education for putting up these slides containing examples from the above mentioned book, on the Internet at the site/url mentioned above.

I would be happy to include one slide at the end of each of the above slide files thanking Pearson Education for permission provided and having specific attribution to the above mentioned book.

Please note that putting up the above slides on the Internet may lead some people to buy the above mentioned book.

Further please note that I am aware of a later edition (5th edition) of the book being available in the market. I may, in future, consider upgrading the course content to use the later edition. At that time I will seek fresh permission from Pearson Education to put the modified/new slides on the Internet.

— end main body of mail to Pearson Education India —

However, I have so far (10th February 2014), not received a response from Pearson Education India for the above mentioned mail.

Today I got a pleasant surprise regarding grant of permission for educational purposes when I looked at an example source code file of chapter 1 (folder named 1) – mysum.cpp. The appropriate part of the commented header section of this file is given below:

* Permission is granted for this code to be used for educational purposes in
* association with the book, given proper citation if and when posted or
* reproduced.Any commercial use of this code requires the explicit written
* permission of the publisher, Addison-Wesley Professional, a division of
* Pearson Education, Inc. …

—- end extract from header comments of source file —

As this blog/website of mine is a free teaching service to students on the Internet, and not-for-profit, I can consider that permission has been granted for me to use code from the above file on this blog. Further, I can use code from all other example code files of the book which carry a similar permission grant statement (which I presume they have, and will confirm before use) on this blog/website. I think that solves my problem. Of course, I will give proper citation on each blog post/web page that uses the book code.

Status update on 17th March 2014

Now I have put up all the required content, suitably modified slightly, on this blog from the C++ course content I had prepared and used to teach the course in the deemed university in Andhra Pradesh, India.

Introduction to C++ Classes

Note: Some of the slides-contents below are repeated from Introduction to C++

C++ Classes

  • Covered in Section 1.5, 1.6, 2.8
  • We will do parts of section 2.8 first

C++ class

  • C++ allows programmers (us) to define our own types (in addition to built-in types like int)
  • These types are known as classes
  • Variables can be defined for these classes just like variables for built-in data types like int

Variable/Object

  • int v1;
    • v1 is a variable of type int
    • v1 is an object of type int

Sales_item class

  • Provides the following operations:
  • >> input operator to read a Sales_item object
  • << output operator to write a Sales_item object
  • + addition operator to add two Sales_item objects
  • = assignment operator to assign one Sales_item object to another
  • same_isbn() member function

Sales_item class – 2

  • These operations/functions of Sales_item are defined elsewhere and accessible to us using header file Sales_item.h
  • Sales_item book;
    • See 1/item_io.cc
    • book is a variable of type Sales_item
    • book is an object of type Sales_item
    • book is an object of class Sales_item (common usage)

Sales_item

  • Multiple objects can be defined of Sales_item
  • Sales_item item1, item2, item3;
    • 3 Sales_item objects have been created
    • Each object will have its own data
    • Similar to multiple variables/objects of built-in types.

struct vs class

  • C++ class has all functionality of ‘C’ struct
  • And has more functionality than struct
  • Note that struct is supported in C++ also and further note that C++ struct is more powerful that C struct.

Type Safety

  • C and C++ are type-safe languages
  • Compiler knows data type of variables/objects and disallows inappropriate operations
    • E.g. Passing a character pointer where a float argument is expected
  • Type-safe languages force some amount of discipline on the programmer (otherwise – lots of compiler error and warning messages).

Object jargon

  • Sales_item item;
  • Based on the above code the following jargon can be used:
    • item is an object of type Sales_item
    • item is a Sales_item object
    • item is a Sales_item
  • This is similar to jargon used for variables/objects of built-in types

Member Functions

  • See add_item2.cc in folder 1
  • A member function is a function defined (provided) by a class
  • Member functions a.k.a. Methods
  • Dot operator used to invoke member function in the context of an object
  • item1.same_isbn(item2)
  • same_isbn() method of item1 is called.

Addition operator

  • Adding two Sales_item objects creates a new Sales_item object whose:
    • ISBN is that of the operands
    • Number sold and revenue reflects the sum of the corresponding values of the operands
    • For input: [ISBN, no. sold, price of each]
      • 0-201-78345 3 20.00
      • 0-201-78345 2 25.00
    • Output is: [ISBN, no. sold, total revenue, average price]
      • 0-201-78345 5 110 22

Running add_item2.exe

  • Build programs in folder 1 by using command make
  • Run add_item2.exe by:
    • $ ./add_item2.exe
    • Will prompt you for Sales_item data (ISBN, no. sold and price of each)
    • Will print out sum

Running add_item2.exe – 2

  • You can run programs which use standard input (cin) against a data file by redirection
  • Data file for add_item2.exe is data/add_item2
  • ./add_item2.exe < data/add_item2
    • Runs add_item2.exe with input taken from file data/add_item2

Redirecting output

  • ./add_item2.exe < data/add_item2 > data/xyzsum
    • Also redirects output to file data/xyzsum
    • Be careful to choose file names different from that already in data
  • Can copy folder 1 to a working directory and safely experiment
    • cp –R src-folder dest-folder
      • Command for recursive (folders and contained sub-folders) copy

Linux User Level Knowledge

  • What are the commonly used Linux text based commands?
  • How to become a power user?
  • What are the commonly used GUI programs on Linux?
  • Check out the Internet for the above

Exercises

  • Copy folder 1 to a working directory
  • ‘make’ the executables in that directory
  • Run program add_item2 with keyboard data and file data
  • Save output of program into a data file and view it.
  • Read add_item2.cc and understand it
  • Go through Linux reference guides for newbies

Think About – Exercise

  • Exercise 1.24 (Section 1.5.2)
  • Program reads several transactions
  • For each new transaction determine if it is the same ISBN as previous transaction
  • Keep a count of how many transactions there are for each ISBN
  • Test program with test data (file)
  • Test data should have multiple transactions with transactions for same ISBN grouped together

Exercise 1.24 & Assignment

  • See avg_price.cc
  • Assignment: Modify avg_price.cc to print individual transactions followed by total sales info (total sales info is as is already given by avg_price.cc)
  • Test your solution with existing data (data/book_sales).
  • If there are bugs in your program mention it as comments in your source code.

Read Course Book

  • Chapters 1 and 2 of course book have been covered (barring few exceptions)
  • Please read chapters 1 and 2 of course book

——–

Note: The course book is C++ Primer, 4th Edition by Lippman, Lajoie and Moo. References above to source files, and use of code within those files, are of example code given in and/or along with the book. As this post is freely accessible on the Internet, not-for-profit, and for educational purposes, based on the permission related statements in the source code, I have considered that permission has been granted to use them here.

Introduction

Why Learn C++?

  • Very powerful and respected prog. Lang.
  • Highly respected in Academia
  • B. Tech./M.Tech. Project work
  • Job Written Test + Interview
  • Research: Programming work can be done in C++

Only course in C++

  • This may be the only course in C++ done by you.
  • So learn it well
  • Benefits, later on in life, can be enormous
  • Excellent Lab facilities
  • Use extra Lab time whenever possible
  • But do not neglect other courses

Course Book

  • C++ Primer, Fourth Edition
  • Authors:
    • Stanley B. Lippman
    • Josee Lajoie
    • Barbara E. Moo
  • Publisher: Pearson Education
  • ISBN: 81-317-1077-7
  • Price
    • List Price: Rs. 475
    • Discount: Usually 10 to 20%

Course Book – 2

  • Availability of hard copy enables:
    • Easy lookup and study
    • Faster and better learning
  • At least one copy for two students is essential
  • Will be useful after course too
  • Procure book quickly
  • Book covers both C and C++
  • Reading chapters of book will be very useful

First C++ Program

  • #include   <iostream>  //Not iostream.h
  • int main()
  • {
    • std::cout  <<  “Hello world\n”;
  • }

First C++ Program – 2

  • C++ is a superset of C
  • Standard header files do not have .h typically
  • The iostream header includes information about stream objects used for input and output.
  • All such stream objects are said to be part of the iostream library
  • Instead of printf we use std::cout

First C++ Program – 3

  • std is a namespace
  • cout is an object which writes (outputs) to a stream (the terminal usually)
  • :: is required between namespace and object
  • << is the way to direct data into cout object
  • << is also called output operator

First C++ Program – 4

  • Source code file extension should be .cpp
  • Save file as firstpgm.cpp
  • Compile using c++ or g++
  • Executable file is named as a.out

Second C++ Program

Second C++ Program – 2

  • << output operator can be used multiple times in one statement
  • std::endl is another way of inserting a newline (\n)
  • Defining int variables is same as C

Second C++ Program – 3

  • std::cin is an input stream object which usually reads from keyboard
  • >> is the input operator which reads input and puts the input into variables on right  hand side of operator

Read Course Book

  • Course book (C++ Primer 4/e):
  • Gives a lot of additional information far beyond what we have time to cover in class
  • Is somewhat precise and so may take getting used to

Read Course Book – 2

  • But it is very good and very accurate
  • Has simple exercises
  • Has nice layout with certain paragraphs marked specially as Notes or Beware (warnings)
  • Reading and understanding it thoroughly will make you a thorough C++ Guru

Hands On (Finally :-))

  • Start your system
  • Choose Red Hat Linux as OS (instead of default Windows)
  • Log on with userid: — and password: —
  • Wait for the GUI (Graphical User Interface) to come up properly
  • Open a terminal window

First Assignment

  • Write the Hello World program using vi
  • Source file name must end in .cpp
  • Compile it using c++ or g++
  • Executable file will be a.out (like what cc does)
  • Run ./a.out

Second Assignment

  • First copy the book code zip file onto your system
  • Unzip the file
  • Now read 1/add.cc
  • Then write a program which takes in four integral numbers and gives the average of them as output.

Introduction – 2

End of Input

  • See 1/mysum.cc (Section 1.44 in book)
  • Use Ctrl-D to signify End of data from Keyboard
  • while (std::cin >> value)
    • Operation is executed
    • std::cin is evaluated (true/false)
    • If operation succeeded cin is true
    • If operation failed (invalid input, end of data) cin becomes invalid and returns false

Sales_item class

  • Chapter 1 of Course Book introduces this class
  • I prefer to skip classes (C++ classes :-)) till later

Chapter 2

  • Variables and Basic Types
  • Built-In types: int, char, long, float, double etc.
  • Literals: 128, 3.14f, ‘a’, “Rama”
  • Variables: int a = 2;
  • variable vs. object: For now we can use the word interchangeably

const object/variable

  • const int bufsize = 512;
  • Value cannot be changed

Temporarily skipping

  • References (Sec. 2.5)
  • Typedefs (Sec 2.6)
  • Enums (Sec 2.7)
  • Will cover them later

C++ Classes

  • Covered in Section 1.5, 1.6, 2.8
  • We will do parts of section 2.8 first

C++ class

  • C++ allows programmers (us) to define our own types (in addition to built-in types like int)
  • These types are known as classes
  • Variables can be defined for these classes just like variables for built-in data types like int

Variable/Object

  • int v1;
    • v1 is a variable of type int
    • v1 is an object of type int

Sales_item class

  • Sales_item book;
    • We assume Sales_item is defined elsewhere and accessible to us using header file Sales_item.h
    • See 1/item_io.cc
    • book is a variable of type Sales_item
    • book is an object of type Sales_item
    • book is an object of class Sales_item (common usage)

Sales_item

  • Multiple objects can be defined of Sales_item
  • Sales_item item1, item2, item3;
    • 3 Sales_item objects have been created
    • Each object will have its own data
    • Similar to multiple variables/objects of built-in types.

struct vs class

  • C++ class has all functionality of ‘C’ struct
  • And has more functionality than struct
  • Note that struct is supported in C++ also and further note that C++ struct is more powerful that C struct.

Type Safety

  • C and C++ are type-safe languages
  • Compiler knows data type of variables/objects and disallows inappropriate operations
    • E.g. Passing a character pointer where a float argument is expected
  • Type-safe languages force some amount of discipline on the programmer (otherwise – lots of compiler error and warning messages).

Object jargon

  • Sales_item item;
  • Based on the above code the following jargon can be used:
    • item is an object of type Sales_item
    • item is a Sales_item object
    • item is a Sales_item
  • This is similar to jargon used for variables/objects of built-in types

Introduction – 3

References

  • Section 2.5 in course book
  • A reference serves as an alternative name for an object
  • In real-world programs, references are primarily used as parameters to functions
  • Reference is different from pointer
  • Defined by preceding a variable name by the & symbol

Reference Example

  • int ival = 1024;
  • int &refval = ival;
  • refval is a reference to ival
  • refval += 2; // adds 2 to ival
  • int i1 = refval; // assigns value of ival to i1

Reference examples

  • A reference MUST be initialized.
  • int &refval2; //error
  • A reference must be initialized using an object of the same type as the reference
  • int &refval3 = 10; // error – initializer must be an object

Reference vs pointer

  • Pointer uses indirection syntax
  • int *iptr = &ival;
  • *iptr = 5;
  • Note that & symbol is used both for references and addresses; From context we know whether it is a reference or an address.

Reference vs pointer – 2

  • Pointer is a separate variable whose value can be independently changed. Reference is only an alias to an object and does not have a separate existence
  • iptr = null;
  • Pointer can be changed to point to another object
  • Reference can never be changed to become an alias for another object

Const references

  • A const reference is a reference that refers to a const object (or literal value)
  • const int ival = 1024;
  • const int &refval = ival; //ok
  • int &ref2 = ival; // error: nonconst reference to a const object
  • const int &r = 42; //ok as it is a const reference

Exercise

  • Solve Exercises section 2.5 from course book. Write observations/answers in a text file
  • Write a program that:
    • Defines double variables
    • Defines non-const and const references to them
    • Defines pointers to them
    • Then write code which uses the references and pointers – objective of the code is to promote your understanding of references.

Typedef

  • A typedef defines a synonym for a type
  • typedef double wages;
  • wages hourly, weekly;
  • typedef struct { … } abc;
  • abc var1;

Enumerations

  • File open mode typically may be one of three values: input, output or append
  • To keep track of openmode we could use three integer constants:
    • const int input = 0;
    • const int output = 1;
    • const int append = 2;
  • int fileopenmode = input; //variable to keep track of mode

Enum

  • Better way to handle situation is to use enum
  • enum open_modes {input, output, append};
  • Defines an enumeration type called open_modes which can hold only one of the three listed values.
  • open_modes fileopenmode = input;
  • Fileopenmode variable is of type open_modes and can be assigned one of its enumerations ONLY.

Enum – 2

  • Enum superior to plain const:
    • validation is automatically performed
    • set of enumerations are defined at one place.
  • enum variables are assigned integral values with first enumeration being 0 by default and the others increasing by 1
  • See enumtest.cpp

Exercise

  • Write an enum type for weekday – Sunday, Monday …
  • Define two variables of that enum type
  • Assign some values for both variables in the program.
  • Print out the day of the week for both variables (string should be printed and not 0 or 1 …)
  • Compare the two variables and print whether they are equal or not.

——–

Note: The course book is C++ Primer, 4th Edition by Lippman, Lajoie and Moo. References above to source files, and use of code within those files, are of example code given in and/or along with the book. As this post is freely accessible on the Internet, not-for-profit, and for educational purposes, based on the permission related statements in the source code, I have considered that permission has been granted to use them here.

C++ Programming

Last updated on 26th March 2014

I taught this course to Ist M.Sc. (Maths) students twice or thrice. The last time I taught the course would have been in 2008. The class size was typically around 20 to 25 students.

The course content consists of:

  • Powerpoint presentations
    • [A few presentation slides have only the topic names and corresponding sections in the book. If time permits and there is a demand I am willing to consider expanding these few slides to be more like the other explanatory slides.]
  • Sample programs (some created by me and some from the course book)
    • [For sample/example programs created by me, as WordPress does not permit .cpp/.cc files to be uploaded I have converted .cpp/.cc files to pdf and then uploaded them. I have also provided an external link to zip files containing these sample/example programs in original file format.]
  • Assignments

The course is based on the book, “C++ Primer, Fourth Edition” by Stanley B. Lippman, Josee Lajoie & Barbara E. Moo. It is published by Pearson Education, http://www.pearsonhighered.com/educator/product/C-Primer/9780201721485.page. Please note that the fourth edition is reported as out of print in the above link and that the newer fifth edition of the book is available. However, pdf versions of the fourth edition book, as of now, can be easily obtained using Google search. The fourth edition book example source code can be downloaded from:

Windows format files: http://www.informit.com/content/images/0201721481/sourcecode/MS_files.zip

Linux format files: http://www.informit.com/content/images/0201721481/sourcecode/gnu_files.tar.gz

If there is demand and time permits, I am willing to consider upgrading this course content to the fifth edition sometime. I have not yet read the fifth edition book in detail and so I do not know whether most of this course content applies to that edition too. The material of this course does not cover the new C++ 11 standard. The fifth edition covers the new C++ 11 standard.

The course has a pre-requisite of the student having learnt ‘C’ programming. It focuses only on those aspects of C++ which are not present in ‘C’. [In many Indian colleges and universities, I believe, students are first taught ‘C’ programming over one or two semesters followed by a semester of C++. This is the environment in which I taught the course.] Further, it explains C++ concepts (over and above ‘C’ concepts) using relatively simple examples and assignments. So a Sales_item class or a string class is used as the example and/or assignment class instead of a somewhat more complicated graphics class. Such an approach I thought was suitable for the I M.Sc. (Maths) class that I taught as the institution did have some significant constraints in lab. time availability for programming work for those students.

For students who would like to do/follow/go through a more rigorous and perhaps time-consuming C++ course, taught at the freshman (first) year in a USA engineering college/university which does not seem to presume prior knowledge of ‘C’ language part of C++, information including links are provided about one such course designed by Prof. Bjarne Stroustrup, creator of C++, towards the end of this post.

Further, please note that, as a first step, I have focused on putting up the course content used by me to teach this course in the deemed university in Andhra Pradesh, India, suitably modified, on this blog. As part of the minor modifications for putting it up on this publicly accessible blog, some errors may have crept in. I have not checked all the modifications for accuracy (due to other demands on my time). If this course (on this blog) does get utilized by students then the errors in the modified part will come to light and will get fixed by me (or others). I think that is a better way of investing my (and others) time for fixing any errors in this course (on this blog).

The course covers the following topics.

1) Introduction to C++

  1. Importance of C++
  2. First C++ program

Powerpoint slides and example source file(s) in pdf format: Introduction.pptIntroduction-2.pptIntroduction-3.ppt and enumtest.cpp.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

2) Introduction to C++ Classes

  1. Notion of Class
  2. How to use a class (as against how to create a class)
  3. Using member functions of a class
  4. Using operators of a class

Powerpoint slides: Classes-Introduction.ppt

3) C++ Standard Library

  1. Std namespace
  2. Using string class
  3. Using vector class (template)
  4. Using ifstream & ofstream classes

Powerpoint slides and example source file(s) in pdf format: stdLibrary1.ppt, stdLibrary2.ppt, fileio.cpp.pdf, filecin.cpp.pdf and countWordNLine.cpp.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

4) Dynamic Memory

  1. Heap & Stack
  2. new expression
  3. delete expression
  4. Dynamic array allocation & deletion

Powerpoint slides and example source file(s) in pdf format: DynamicMemory.ppt, DynamicMemory2.ppt, newdelete.cpp.pdf, ccharstr.cpp.pdf and newsimple.cpp.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

5) Functions

  1. Quick mention of C ‘functions’
  2. Reference parameters
  3. Default arguments
  4. Inline functions
  5. Class Member functions
  6. Scope of functions (Global & Class)
  7. Overloaded functions
  8. Function matching & Function Overload resolution
  9. Argument conversions

Powerpoint slides and example source file(s) in pdf format: Functions.ppt, Functions2TopicsOnly.ppt, Functions3.ppt, swap1.cpp.pdf, strparm1.cpp.pdf, swap2.cpp.pdf, strparm2.cpp.pdf, fnscope.cpp.pdf, fnscopeErr.cpp.pdf, ovlfns.cpp.pdf, ovlfns2.cpp.pdf and ovlfnsconv.cpp.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

6) Classes (Creating own classes as against using supplied classes)

  1. Data Abstraction
  2. Data Encapsulation (Data Hiding)
  3. Class Definition; Difference between class definition and class declaration
  4. Constructors
  5. Friends
  6. static class members

Powerpoint slides and example source file(s) in pdf format: Classes2TopicsOnly.ppt, g.cpp.pdf and static.cpp.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

7) Copy Control, Assignment Operator and Destructor

  1. Copy constructor
  2. Copy initialization
  3. Synthesized copy constructor
  4. Argument copy of class object
  5. Copy of object returned by a function
  6. Own copy constructor; when is it necessary?
  7. Assignment operator overload
  8. Synthesized assignment operator
  9. Own assignment operator overload; when is it necessary?
  10. Shallow Copy vs. Deep Copy
  11. Quick mention of other operator overloads (+, -, == etc.)
  12. What is a destructor?
  13. When does it get called?
  14. Destructor syntax
  15. Synthesized destructor
  16. Own destructor; when is it necessary?
  17. Rule of Three

Powerpoint slides and example source file(s) in pdf format:

ClassesCopyControl.pptClassesCopyControl2.pptClassesCopyControl3.ppt,

return.cpp.pdfourstring.cpp.pdfourstring2.cpp.pdfourstring3.cpp.pdf,

ourstringNoCC.cpp.pdfourstringAssignOp.cpp.pdfourstringAssignOp2.cpp.pdf,

ourstring4.cpp.pdf and ourstring5.cpp.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

8) Inheritance

  1. Simple inheritance example
  2. Derived class & Base class
  3. Invoking methods through pointers
  4. Invoking method through base class pointer or reference
  5. Virtual functions
  6. Inheritance hierarchy
  7. Dynamic binding/Polymorphism
  8. Pure virtual functions

Powerpoint slides and example source file(s) in pdf format: Inheritance.ppt, Inheritance2.ppt, Inheritance3.ppt, inherit.cpp.pdf, inherit1.cpp.pdf, inherit2.cpp.pdf, inherit3.cpp.pdf, shapes1.cpp.pdf, shapes2.cpp.pdf, shapes3.cpp.pdf and vecshapes1.cpp.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

9) Exception Handling

  1. Exceptions are run-time anomalies
  2. ‘C’ program error handling; Painful
  3. Exceptions to the rescue in C++
  4. throw
  5. try-catch
  6. What if there is no try-catch?
  7. Java, C# exception usage
  8. Exception class hierarchy
  9. Multiple catch handlers
  10. Functions exited during search for an exception handler
  11. Multiple try-catch

Powerpoint slides and example source file(s) in pdf format: Exceptions.ppt, Modexception_example.cpp.pdf, except2.cpp.pdf, except3.cpp.pdf and except4.cpp.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

10) More on Std. Library

  1. Container classes & Generic algorithms
  2. Sequential Containers & Associative Containers
  3. Std. Library design
  4. pair
  5. map; how to use it
  6. iterators; vector & map iterators
  7. set; how to use it

Powerpoint slides and example source file(s) in pdf format: StdLibmap.ppt, word_count.cc.pdf, word_count1.cc.pdf and word_count2.cc.pdf. Example source file(s) (my own, if I recall correctly, and so different from book example code) in original file format – zip file.

Former Student Feedback Comments

A former student who was taught this course by me in the deemed university in Andhra Pradesh, India, wrote the following over email on March 18th 2014 (modified slightly to fix a couple of minor grammatical errors):
It is great that you have shared the C++ programming teaching material prepared by you on your blog. I really hope that people make use of it for I know how useful it could be. I can say this as a direct beneficiary of this, and today that is what fills my bank account at the end of every month.

I just hope and pray that Swami gives you the strength and determination to keep up the good work. I also think that I too can take a tiny part of the credit in this endeavour of you putting up these slides, as I was perhaps one of the many who would have suggested that you put these slides up in some forum accessible to the students’ community. Thank you for considering the request.

Prof. Bjarne Stroustrup’s book and course on C++

Prof. Bjarne Stroustrup, creator of C++, teaches C++ at Texas A&M university (TAMU). The course is based on his book, Programming — Principles and Practice Using C++. Here’s the book support page: http://www.stroustrup.com/Programming/. An extract from the book support page, “This book is based on a course I designed for engineering freshmen at Texas A&M University. It has now been taught by me and others, at TAMU, and elsewhere, in academia and industry, for almost five years and to thousands of students. It is currently available in (physical and web) book stores.” This page also has a link to lecture slides (for teaching C++).

Note about Course Book Source Code Copyright

The course book (C++ Primer, 4th edition) source code files have permission for usage statements as comments in the beginning of the files. As an example a source code file of chapter 1 (folder named 1) – mysum.cpp has the following comments towards the beginning of the file:

* Permission is granted for this code to be used for educational purposes in
* association with the book, given proper citation if and when posted or
* reproduced.Any commercial use of this code requires the explicit written
* permission of the publisher, Addison-Wesley Professional, a division of
* Pearson Education, Inc. …

—- end extract from header comments of source file —

As this blog/website of mine is a free teaching service to students on the Internet, and not-for-profit, I can consider that permission has been granted for me to use code from the above file on this blog. Further, I can use code from all other example code files of the book which carry a similar permission grant statement on this blog/website. Of course, I have given proper citation on each blog post/web page and Powerpoint slides file that uses the course book code.

The status history regarding the permission issue and putting up the C++ course contents on this blog is available here.