a. inheritance b. composition c. static and dynamic binding d. virtual member function e. pass by reference
Addition of Two Numbers
Adding two numbers in programming is essentially the same as adding two numbers in general arithmetic. A significant difference is that in programming, you need to pay attention to the data type of the variable that will hold the sum of two numbers.
C++
C++ is a general-purpose hybrid language, which supports both OOPs and procedural language designed and developed by Bjarne Stroustrup. It began in 1979 as “C with Classes” at Bell Labs and first appeared in the year 1985 as C++. It is the superset of C programming language, because it uses most of the C code syntax. Due to its hybrid functionality, it used to develop embedded systems, operating systems, web browser, GUI and video games.
My C++ reading next week covers the below topics. I find it easier to understand the material when I have a working code example that I can break down part by part as I read. I am looking for a single C++ code (perhaps around 30-50 lines of code) that I can run in Visual Studio and make it compile and run showing how to use: (Doesn't need to be complicated, I am in my 6th week of learning C++)
a. inheritance
b. composition
c. static and dynamic binding
d. virtual member function
e. pass by reference
a. Inheritance
In inheritance, a class can derive features and methods from another class.
A sub class is the class which inherits properties from another class.
A super class or a base class is the class whose properties are inherited by a sub class.
Example-
Let class A be a super class and class B be the sub class.
class A{
public:
int num;
void setnum(int n){
num = n;
}
};
class B: public A{
int num2;
};
In the above code, class B is publicly inherited from class A.
Step by step
Solved in 5 steps with 2 images