Тёмный
No video :(

27 Operator Overloading And Constructor Overloading in C++ zoom | C++ Programming Tutorial beginners 

tech fort
Подписаться 10 тыс.
Просмотров 25
50% 1

#Operator Overloading in C++ :
- Operator overloading is a compile time polymorphism in which the operator is overloaded to provide the special meaning to the user defined data type.
- Operator overloading is used to overload/redefine the operators in C++
- Capability to add the variables of the user defined data type
- Operator that cannot be overloaded are as follows:
Scope operator (::)
sizeof
member selector(.)
member pointer selector(*)
ternary operator(?:)
Syntax of Operator Overloading:
-------------------------------
return_type class_name ::operator op(arg_list)
{
// body of the function.
}
Where the return type is the type of value returned by the function.
class_name is the name of the class.
operator op is an operator function where op is the operator being overloaded, and the operator is the keyword.
Constructor overloading in C ++ :
constructor Overloading can be defined as the process of having 2 or more constructor with same name, but different in parameters is called as Constructor overloading in c++,
- constructor name same
- number of parameter
- type of parameters
- order of parameters
#include iostream
using namespace std;
class ConOverDemo{
private:
int id;
string name;
float price;
int qty;
public:
ConOverDemo(){
cout "

Im in 0 Parameter constuctor";
}
ConOverDemo(int id){
this id=id;
cout "
Im in 1 Parameter constuctor" this id;
}
ConOverDemo(int id,string n,float p,int q){
this- id=id;
name=n;
price=p;
qty=q;

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии    
Далее
Почему-то хочется плакать
00:17
Просмотров 500 тыс.
Brutally honest advice for new .NET Web Developers
7:19
How computer processors run conditions and loops
17:03