CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//comma operator discard first value inside ()
//but {} is taking two different arguments
#include <iostream>
using namespace std;
class UDT
{
public:
UDT(int a,int b= 10) : m_a(a),m_b(b)
{//cout << "Ctor\n";
}
~UDT() {//cout << "Dtor\n";
}
UDT(const UDT&) {cout << "Copy Ctor\n";}
UDT& operator=(const UDT&) {cout << "Copy asignmnt\n"; return *this;}
UDT(UDT&&) noexcept {cout << "Move Ctor\n";}
UDT& operator=(UDT&&) noexcept {cout << "Move asignmnt\n"; return *this;}
void display()
{
cout << m_a << " " << m_b << endl;
}
private:
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run