In C++ it is possible to cast child class reference variable to parent class Reference.
When ever we are Converting a derived-class reference or pointer to a base-class reference or pointer is called implicit typecasting/upcasting. It is it quite natural also. A samaller data type can be casted to bigger one that won't make any data loss.
The downcasting/explicit typecasting, are the opposite of upcasting, is a process converting a base-class pointer or reference to a derived-class pointer or reference. It won't be done by the compiler implicitly.
Function prototype tells compiler about number of parameters function takes, data-types of parameters and return type of function. By using this information, compiler cross checks function parameters and...
Introduction
Before we proceed with understanding as to how to create a class in c++, we need to first understand the what is a class.
Definition : A class is a container of related data and methods...
Q. Swap two numbers using the following function. Complete the function. You won't be allowed to use a temporary variable to swap the two numbers.
void swap ( ... )
{
/* Swap code goes here */
}
...
Advantages of C++
- C++ is a profoundly convenient dialect and is frequently the dialect of decision for multi-gadget, multi-stage application advancement.
- C++ is a protest situated programming dialect...
The definition:
void main() { /* ... */ }
Is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1 or the ISO C standard 5.1.2.2.1. A conforming...