Many a times C++ is regarded as replacement of stdio.h in C by iostream in C++, printf and scanf in C by cout and cin in C++ and structure in C by class in C++...
My objective is to take this course beyond that myths and impressions...
Learning C++ is not just syntax but far more than that. OOP was one of the revolution in s/w industry. Here is an attempt is made to teach concepts of C++ from philosophical point of view and not mere from programming perspective. OOP and C++ are the way we live, behave, act, respond, and exist in the world...!
I am making attempt in the world by mapping each implemented concept of OOP in C++ by mapping it to the real world. May be its first attempt in the world to teach in this manner by using animation.
Besides all features of C++ with OOP along with step by step explanation, I am going to put here notes, quiz, interview questions along with answers and assignments as well.
I am sure if understand the basics, Java, PHP, Python would not only be an easy cakewalk but you would love learning those in the future. So I am using numerous day-to-day examples to explain concepts.
Course starts from basics of programming methodologies and then covers each feature of C++ with detail analysis rather than mere explanation of programs.
Here in this video I am introducing about me and the course
You can’t trust code that you did not totally create yourself...!
Here is the scope of subject and methodology which I am going to follow to explain the Object Oriented Programming with C++. Hope you enjoy my way of teaching.
A language that doesn’t have everything is actually easier to program in than some that do...!
If you don't know where you are going, road will get you there...!
After knowing history let's see the future...!
Measuring programming progress by lines of code is like measuring aircraft building progress by weight...!
If you have written C program, here is the methodology which you followed while writing C programs
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it...!
This is just an overview of OOPs methodology in a nutshell
The main object of religion is not to get a human into heaven, but to get heaven into him...
Without history, there would be no future...!
In order to be irreplaceable, One must always be different...!
The objects are very beautiful and important in and of themselves, but also because of the story they tell...
Sarcastic Saying..."Men will be Men"....and..."Boys will be boys"...
What's wrong in that...?
After all object are an instance of Class...!
Sometimes abstraction and encapsulation are at odds with performance — although not nearly as often as many developers believe — but it is always a good practice first to make your code right, and then make it fast...
Upper classes are a nation's past;
The middle class is its future
"Abstraction is selective ignorance...!"
The complexity of the problems you are able to solve is directly related to the kind and quality of Abstraction
Everywhere you look, you see them - objects..! People, animals, planes, cars, buildings, computers and the like. Human think in terms of objects. We have the marvelous ability of abstraction that enables us to view screen images as objects such as people, plane, trees, and mountains rather than as individual dots of color. We can, if we wish, think in terms of beaches rather than grains of sand, forests rather than trees, and houses rather than bricks...!
This method is to define as the class number of a class the class of all classes similar to given class...!
One Ring to Rule them all,
One Ring to find them,
One Ring to bring them all
and in the darkness bind them.
---John Ronald Reuel Tolkien
Only God can turn a Mess into a Message...!
A Message prepared in the mind reaches a mind...A message prepared in a life reaches a life...!
God sends you lot of messages...Keep your senses open to receive them...!
In this dynamically changing world, you often take decisions dynamically...Don't you?
This penultimate topic covers applications of OOPs in the software industry.
Here we come to the end of first chapter... It was just introduction to two mmethodologies viz. POP & OOP.
Summary video would help you to recall everything learnt so far in this chapter...
Here is a fast quiz on fundamentals of OOPs
Here are a few assignments for you. You can discuss along with other students in the class and explore it
What do you do when you plan to purchase any new gadget...? Ask this question to yourself and answer before you start this unit...!
Here is first set of differences between C and C++. You would learn various minor and major differences like commenting style in C and C++, size of character constant, difference in meaning of empty parenthesis in front of function, compilation rules, placement of variables declaration, initialization of global variables etc. in C and C++.
Don't just listen but pause while you view the code. Type it. Observe output in C and C++ compilers separately. I advise you to use old TC compiler for understanding the beauty of C as well as enhancement made by Stroustrup in C++.
Old TC compiler is available on the internet.
Note: You may find some different outputs than mentioned in the video. But I just want you to understand the attempts behind the possible enhancement.
Here is second set of differences between C and C++ wherein you would learn how tag name of user defined data type differs between C and C++, const modifier, how return type of main function defers, how string constants are handles by C and C++, need of function prototype, type casting, new concepts like void pointer, compiler-only table etc.
Here is third and final set of differences between C and C++. The topic starts with difference in default access category of structure in C and class in C++, and then it is followed by various concepts like scope resolution operator and typecasting methods in C and C++.
Although it is possible to write portable programs, there are many programs among different C and C++ compilers and different computers that can ,make portability difficult to achieve. Simply writing programs in C and C++ does not guarantee portability. The programmer will often need to deal with compiler and computer variations.
Here is summary of the topic. A small but very interested story has been narrated here for you. If you have enrolled for my other course "Demystifying C programming language" then you can skip this story.
Take a Break...Take a Quiz
The quiz is designed to refresh your knowledge of C programming as well along with C++
"I love nick names. It makes me feel loved. It makes me feel less alone in this world...!"
Here in this topic you would be introduced to a new topic which is a wonderful facility directly imported from real world.
Here is review of two popular concepts from functions in C i.e.
Review is taken to understand power of reference variable in a better way.
Here you will learn everything about reference variable in C++ i.e. syntax of reference variable and tips to use it appropriately.
Your computer and compiler are good teachers. If after carefully reading your C++ language manual you are not sure how a feature of C++ works, experiment using small test programs like in the previous chapters and see what happens. Se your compiler options for "Maximum warnings". Study each message you get when you compile your programs and correct the program to eliminate the message.
Here is a sample program to understand theory learnt so far in last topic
Here is a single problem solved with three methods i.e.
Swapping contents of two variables using or without using 3rd variable has been second most popular program in while learning any hardcore computer programming language after famous "Hello World" program. And why not it should be? After all, any operating system works on this basic principle...!
Here is the interesting program using reference variable
Here is the last video in this chapter which explains use of const while handling reference variable in C. At the end you would get to answers to 3 small but cryptic questions in this chapter.
It's a break...Quiz time break
Here is introduction to new small topic "Default function arguments". Try to understand its importance. The concepts has been intelligently used by many programming languages while writing libraries. I bet you, its really interesting feature of C++.
The arguments in function having default values can be categorized as Mandatory arguments and default arguments. Here is syntax of default arguments along with meaning of mandatory arguments and default arguments. Examples are hypothetical for understanding purpose only. Explore its use by thinking on your own.
Here is a sample program written on the basis of real life example. Its a hypothetical program written in 3 different files for exploring power of default function arguments in C++
Take a break...Take a quiz
Memory allocated to variables can be at either compile time or at run time. Here is introduction to dynamic memory allocation
Here is explanation of everything about memory with the aid of animation...like data segment, logical partitions, scope and life etc. of variables and focus on heap
Here is first function from C, for allocation of memory dynamically. Its a library function.
Here is explanation of one more memory allocation function calloc(). The video also covers explanation of the function free() which releases the memory from the heap.
Memory taken dynamically may proved to be insufficient and in such case the library function realloc() helps you to request for additional memory at run time. Here is how it works...
Here we are to study how memory can be taken from the heap at run time in C++.
new in C++ is versatile operator proposed by Prof. Stroustrup. Here is more about new in C++.
Here is summary of this chapter so far we learnt.
A short Break...It's Quiz time
A physician, a civil engineer, and a computer scientist were arguing about what was the oldest profession in the world.
The physician remarked, "Well, in the Bible, it says that God created Eve from a rib taken out of Adam. This clearly required surgery, and so I can rightly claim that mine is the oldest profession in the world."
The civil engineer interrupted, and said, "But even earlier in the book of Genesis, it states that God created the order of the heavens and the earth from out of the chaos. This was the first and certainly the most spectacular application of civil engineering. Therefore, fair doctor, you are wrong: mine is the oldest profession in the world."
The computer scientist leaned back in her chair, smiled, and then said confidently, "Ah, but who do you think created the chaos?"
Here is introduction to classes and objects in the world...!
Class in C++ resembles structure in C. Though both are user defined data types, major difference exists between class and structure. Here is brief about structure in C. Might be revision for you. But take it.
Let's have a look at difference between structure in C and class in C++.
In C you might have heard the term "Data Type". This type has been given new dimension in C++. Here it is how...!
Here is how class in C++ can be designed...
It's the Encapsulation, which gives you the power of Data Hiding and Data inaccessibility... Here is more about Encapsulation in C++
Here is roles of access specifiers viz. private, public and protected while designing the class
Here is the video which explains information that can be retrieved by user of a class just by looking at the class design.
Here is first program of C++ using class. You would find detail analysis of scope resolution operator at the end of the topic.
The Question "How does one write good programs in C++?" is very similar to the question "How does one write good English prose?" There are two answers: "Know what you want to say" and "Practice. Imitate good writing". Both appear to be appropriate for C++ as they are for English - and hard to follow.
Here is inside view of typical C++ program written using class
Let's feel the pains if we have to mimic the class program in C++ using structures in C
Here are very interesting sample codes to create instance on the stack, an array of instances, an instance on the heap and and an array of instances on the heap.
In the last century "Landline" phone used to be popular gadget at home as well as commercial premises. Then came the mobile, "a personal gadget". However both has got it's own pros and cons.
"Inline functions in C++", I would say is same kind of mechanism....!
Don't take it literally :)
Here is the video to extend default functions arguments learnt in the 4th chapter in the context of "Class in C++"
Here is discussion about const member functions in a C++ class.
Like variable of primitive data type, reference to instance of user defined class can be created. This is exhaustively used while writing C++ applications. Listen carefully the philosophy behind this concept.
"A true relationship has tears"
Here is a video which explains relationship between container class and containing class.
Both programs explained have been attached herewith in resources so that you can type, compile and execute them to explore intricacies of containing class relationship.
Here is the last topic of this chapter. Try to understand the program. Study it carefully before you go to the next chapter.
Please don't take this quiz right now if you are absolutely new to C++ programming language. This is going to last topic only after a few more topics are uploaded. Thank you for reaching here and your patience.
This topic is continuation to the last topic in last chapter. You would understand this chapter only when you have understood philosophy of class containing pointer data member.
In this topic you will understand everything about basics of constructor like its syntax rules, when it is called, and when not called.
Here is a counterpart of constructor in the previous topic and it is Destructor in C++. I have taken small and simple programs on the background of animation to explain flow control and concepts. You need to be very carefully as you need to given attention on various parts of the screen at a time.
Here is one of the important concept of the constructor i.e Default Constructor. It is usually expressed in single line. But I am elaborating it taking its importance into consideration.
So in all programs written till date were having a default constructor (hidden though) supplied by the constructor.
Try to apply analogy in our day-to-day life if you can after completion of this topic. Human too behave like a compiler.
Constructor taking single argument is different than constructor taking multiple arguments. So this case is dealt here separately. Try to understand the importance.
The video explains you need of writing default constructor if user takes part in writing explicit constructors for instance initialization. The source code is attached here for download.
Here is a program of constructor taking two arguments. Try to understand importance and difference between constructor taking single argument and multiple arguments. Source code is attached so that you can try it on your own machine
When you give some article as a gift to anybody you love, you wrap it in a "Gift box". Though this "Gift box" is temporary, it is necessary. The temporary instance in C++ is the same which is created internally by the compiler. Your job as a programmer is to make provision by way of provision of a suitable constructor. The same is explained it here. The concept is difficult to understand by reading book. So extensive animation is used to explain the same. I hope you understand the underlying philosophy.
The source code is made available for downloading so that you can test the program on your machine and understand control flow of each step.
Here is a small program containing class having constructor taking two arguments with default values. Source code is also provided to download. Try this program on your machine.
Initializing 1 instance with existing instance is one of the important feature of Copy Constructor.
Though compiler provides default copy constructor, it's of no use if class data member is of pointer.
Study the program carefully to understand Shallow Copy
In this video you would understand
Note: Programs explained in the video are made available to download. Don't copy programs but type them on your own.
Though constructor is said to be used for initialization of an object at the time of creation, it's not true initialization but and assignment.
Here is video which explains difference between an Initialization and an Assignment in C++ context
Here is the solution provided by Stroustrup to address issues in the last topic. You would learn
Here is I am with one more important topic to discuss special features of Class in C++. This would be introduction to this topic "Special Class Features".
The topic is difficult to understand. Try to listen and view contents of the video. I am trying to convey, how member function of the class knows which instance he is going to act.
It is the special pointer called "this pointer" which makes it possible.
Since, the concept of "this" pointer is difficult to understand, I am taking two similar looking programs. First is in C++ language and second in C language performing same task in same manner.
You would be able to understand
Here is wonderful application of this pointer. It's not just an application but is a special feature of C++ provided by Stroustrup.
Functions in C++ can be concatenated and topic shows how to achieve it.
You would learn mystery behind the screen
At the end of this small topic, you will understand
Here are two programs to understand fundamentals of static data.
In the next topic I have provided source codes of static data member of containing class.
At the end of this topic, you would be able to understand importance and syntax of static member function. Source codes explained in the video have been made available for download.
You would learn what is the friend function in C++ at the end of this topic.
Here is a sample program to understand implementation of friend function in C++
You would learn
Here we come to the end of this chapter.
Here is an Introduction to Polymorphism in C++
You will learn 5-steps algorithm of argument matching while calling a function.
You would learn how function is called at compile time when multiple functions are available in the class according to the first rule "Exact match" and sub rule "Trivial conversion".
When first rules fails, compiler goes for matching using promotion. This involves argument promotion from
Here are second set of argument matching rules as:
In this video you will get a glimpse of an important concept called "Name Mangling". Concept is based on the "Function overloading in C++". If you fail to understand how to view the object file, feel free to ask me.
If you want to explore further, you can download the PDF file attached here in the resources and try,
Don't get confused by the title. Operator overloading is not available in C. However I am just trying to convey that Stroustrup found roots of "Operator Overloading in C++" in the C language through his eyes. Just try to understand what I mean in this video.
Here is a video to understand operator overloading in C++. View and listen the contents carefully. Watch it again and again if you fail to understand the concept completely.
Here is a video which is going to explain you what goes under the hood when you overload the operator in C++. You would also learn the much awaited concept of C++ i.e. cout and cin and its connection along with various previous concepts like this pointer, object, class, function chaining, and operator overloading.
Here are rules of overloading unary and binary operators for member as well as global friend functions. Carefully view and listen functional notation of infix notation.
Here is a program to explain operator overloading concept for both unary as well as binary operators. I have taken a user defined String class for explaining almost all concepts you learned since the first chapter of this course.
I am keeping source code of this program in download section.
Carefully study the program
Here is a very interesting program to understand "how compiler differentiate between post-fix and prefix increment operator as a part of expression".
The program is followed by the summary
The feature "Inheritance" of OOPs has been discussed earlier. Now in this chapter we will see ways to implement it. This chapter takes a quick introduction to Inheritance
Here is a simple example of Inheritance in action before we study the syntax in the next topic,
Here is a definition of Inheritance followed by the general syntax.
This video explains behavior of class members of base class when a new class is derived from an existing class and if type of derivation is private.
In this video you would understand what happens to private members of base class and public members of base class in inheritance.
Here are a bit complex concepts of inheritance to explain in best possible way. Listen to this video carefully again and again.
Here is summary of access specifier. So you would learn what happens with private, protected and public members of the base class when they are inherited with private, public and protected derivation. Listen carefully. Listen again and again. It will take some time to imbibe the concepts.
Here is a first program to understand:
At the end you will also learn, the summary of compiler look-up rules to access data as well as functions
As discussed in the last chapter, function overloading can occur in the single scope. So when you redefine the function in case of inheritance, you are not actually overloading but overriding it. Two programs explained in the video make it clear. Same programs have been added in the resource for ready reference.
Here is a video to see how constructor and destructors are called when class is inherited. You would understand that it is the responsibility of derived class to call base class constructor explicitly in base-member initialization list.
Here is the modified version of the previous program wherein I am explaining "How to initialize one instance of the derived class using existing class" by appropriate use of copy constructor
Here is operator overloading in Inheritance. We have already seen a separate chapter how to overload an operator in single class. This video explains method to overload an assignment operator when class is derived. I am taking a simple program to understand difficult concept of inheritance. Listen and view the program flow, code statements, design and syntax again and again to understand the program philosophy.
The source code is provided in the resources section for downloading.
Programs in this chapter are difficult to understand so please be careful while watching these videos in this section as well as previous sections of this chapter.
Here is a video to understand casting of base class instance into derived class, particularly when instance is created on the heap at run time.
Many such concepts last few topics and this are seemingly pure theoretical. However these concepts would definitely help you in the future. So as of now don't think about its application or use while writing programs at academic level.
However, this knowledge would definitely help you to face serious interview questions...!
Here is a video to understand casting of derived class instance into base class, particularly when instance of derived class is created on the heap at run time and stored in the base class pointer.
Many such concepts last few topics and this are seemingly pure theoretical. However these concepts would definitely help you in the future. So as of now don't think about its application or use while writing programs at academic level.
Post graduate Engineer... Computer Programming language trainer for last 15 years... Passionate about teaching and have taught personally over 3500 students. Currently my team is developing unique methodology for teaching programming language to the masses at lowest possible price. My team has tried to develop absolutely out of the box e-learning contents similar to Crafting a diamond.... for those who want to understand language concepts...