Code
Code
INPUT:
Private:
Int a,b;
Public:
Cons(int x, int y)
A=x;bay;
Cons (int x)
Ax;
Cout<<”CONSTRUCTOR OF 1 PARAMETER\n”<<<<endl;
Cout<<”CONSTRUCTOR OF PARAMETER\n”;
Cons()
Cons(cons &c)
};
Int main()
Cons obj1(21,51);
Cons obj2(51);
Cons obj3;
Cons obj4-obj1;
C:\Users\ASUS\OneDrive\Desktop\New
Vscode.cpptools-1.17.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe”
Return 0;
OUTPUT:
PS
MIEngine-In-b2tmp14c.szt’
MIEngine-Error-bpo5jeyc.kyr’
CONSTRUCTOR OF 2 PARAMETER
21 and 51
CONSTRUCTOR OF 1 PARAMETER
Folder>
& ‘c:\Users\ASUS\.vscode\extensions\ms
--stdout-Microsoft-MIEngine-Out-1dymb4uo.isk’
--stdin-Microsof –stderr-Microsof
--pid-Microsoft-MIEngine-Pid-qclegju2.1ms
dbgExe=C:\msys64\mingw64\bin\gdb.exe’ –interpreter-mi
51
CONSTRUCTOR OF 8 PARAMETER
21 and 51
PS C:\Users\ASUS\OneDrive\Desktop\New folder>
2.
INPUT:
#include<iostream>
Class decons
Public: decons()
PROGRAM-24 (Destructor)
Cout<<”HELLO, I AM A CONSTRUCTOR.”<<endl;
-decons()
};
Cout<<”BYE, I AM A DESTRUCTOR.”;
Int main()
Decons obj;
Return 0;
OUTPUT:
MIEngine-In-3mfhxu5g.okp –[email protected]’--stderr-Microsoft-
MIEngine-Error-czpu1143.1d3’
--pid-Microsoft-MIEngine-Pid-xgxmoaiw.2mh’—
dbgExe=C:\msys64\mingw64\bin\gdb.exe –interpreter-mi
HELLO, I AM A CONSTRUCTOR.
BYE, I AM A DESTRUCTOR.
PS C:\Users\ASUS\OneDrive\Desktop\New folder>
3.
INPUT:
#include<iostream>
#include<string>
Class mypgm
PROGRAM-25
Public:
Int mynum;
String mystring;
};
Int main()
Mypgm myobj;
Myobj.mynum-90;
Return 0;
OUTPUT:
90
HELLO ENGINEERS!!
PS C:\Users\ASUS\OneDrive\Desktop\New folder>
4.
PROGRAM-26
INPUT:
#include<iostream>
Class institute
Public:
Void display()
Cout<<”NAME:”<<name<<”\nBRANCH:”<<branch<<”\nRANK: “<<rank<<endl;
};
Int main()
Institute obj2(“ANISH”,”MIN”,2);
OUTPUT:
PS C:\Users\ASUS\OneDrive\Desktop\New folder> &’c:\Users\ASUS\.vscode\extensions\ms-
vscode.cpptools-1.17.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe’ ‘—stdin-Microsoft-
MIEngine-In-Byqhf445.vyr’ ‘—stdout-Microsoft-MIEngine-Out-tzyezzm5.33t’—stderr=Microsoft-
MIEngine-Error-sklvnics.yhb –pid-Microsoft-MIEngine-Pid-ilpaltu2.riq’ ‘—dbgExe=C:\msys64\mingw64\
bin\gdb.exe –interpreter-mi’
NAME: SWATANTRA
BRANCH:C.S
RANK:1
NAME: ANISH
BRANCH:MIN
RANK: 2
PS C:\Users\ASUS\OneDrive\Desktop\New folder>
5.
INPUT:
Class pgm
Public:
Void display()
PROGRAM-27
};
Int main()
{
}
Pgm obj;
Obj.display(); return 0;
OUTPUT:
Vscode.cpptools-1.17.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe’—stdin-Microsoft-
MIEngine-In-qhp3ubvj.kxb’ ‘—stdout-Microsoft-MIEngine-Out-stgjeqiz.2iq’ ‘—stderr=Microsoft-
MIEngine-Error-x15mkrrr.paj
--pid-Microsoft-MIEngine-Pid-q51sce3r.who
dbgExe=C:\msys64\mingw64\bin\gdb.exe’ –interpreter-mi’
PS C:\Users\ASUS\OneDrive\Desktop\New folder>
--
6.
INPUT:
#include<iostream>
Class pg
Public:
Void display();
};
Void pgn::display()
PROGRAM-28
Int main()
Return 0;
OUTPUT:
--stderr=Microsoft-
PS C:\Users\ASUS\OneDrive\Desktop\New folder>
7.
INPUT:
#include<iostream>
};
Public:
Cout<<x<<”+”<<y<<”=”;
Return(x+y);
Int main(){
Pgm obj;
Cout<<obj.add(20,35); return 0;
OUTPUT:
28+35=55
PS C:\Users\ASUS\OneDrive\Desktop\New folder>
8.
INPUT:
#include<iostream>
Public:
PROGRAM-31 (Inheritance)
Void show()
1
Public:
};
Void print()
Cout<<”HELLO,I am derived class and I am going to call member function of the base class”;
Int main()
OUTPUT:
HELLO, I am derived class and I am going to call member function of the base class.f HELLO,I am the base
class.
PROGRAM-32
(Function overriding)
INPUT:
#include<iostream>
Class base
Public:
Void show()
}
};
Public:
Void show()
Cout<<”HELLO, I am the overidden function of base class inside the sub class.”;
};
Int main()
OUTPUT:
HELLO, I am the overidden function of base class inside the sub class.
10.
(Function overriding)
INPUT:
#include<iostream>
Public:
Void show()
{
}
};
};
Public:
Void show()
Cout<<”HELLO, I am the overidden function of base class inside the sub class.”;
Int main()
Sub ob;
Ob.show();
11.
TNPUT:
Class cons
Private:
Int a,b;
Public:
(
Awx;bay;
Cons(int x)
A=x;
Cout<<”CONSTRUCTOR OF 1 PARAMETER\n”<<a<<endl;
Cons()
Cout<<”CONSTRUCTOR OF PARAMETER\n”;
Cons(cons &c)
};
Int main()
Cons obj2(51);
Cons obj3;
Cons obj4-obj1;
Return 0;
OUTPUT:
PS
C:\Users\ASUS\OneDrive\Desktop\New
Folder>
&
Vscode.cpptools-1.17.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe” –stdin-Microsoft –
stdout Microsoft-MIEngine-Out-1dymb4uo.isk’
MIEngine-In-b2tmp14c.szt’
‘c:\Users\ASUS\.vscode\extensions\ms
--stderr=Microsoft
MIEngine-Error-bpo5jeyc.kyr’
--pid-Microsoft-MIEngine-Pid-qclegju2.1ms’
dbgExe=C:\msys64\mingw64\bin\gdb.exe’ –interpreter-mi
CONSTRUCTOR OF 2 PARAMETER
21 and 51
CONSTRUCTOR OF 1 PARAMETER
51
CONSTRUCTOR OF PARAMETER
21 and 51
PS C:\Users\ASUS\OneDrive\Desktop\New folder>
12.
INPUT:
#include<iostream>
Class functoverload
Public:
PROGRAM-35
(Function overloading)
Void show(int x)
};
Int main()
Functoverload ob;
Ob.show(21,11);
Ob.show(101);
Ob.show(181,121.11);
Return 0;
OUTPUT: