Upload
utkarsh-bajpai
View
216
Download
0
Embed Size (px)
Citation preview
7/26/2019 Constructor Assignment C++
1/4
Constructor AssignmentQ.1 What is the diference between the constructor and normal unction?Q.2Find out errors in the ollowing program:class number{int x=10;foat y;number(){ x=y=10;}
public:number(number t){x=t.x; y=t.y;}
~ (){cout
7/26/2019 Constructor Assignment C++
2/4
}7oi ecture() ,,-unction ${coutote o5 t&an+s"
7/26/2019 Constructor Assignment C++
3/4
{ime=y;oints =p;}*atc&(*atc& O*); ,, /onstructor $};(i) /reate an ob!ect# suc& t&at it in7o+es /onstructor 1.(ii) 4rite complete ePnition 5or /onstructor $.). Answer the "uestions #i$ and #ii$ ater going through the ollowing class:
class player{int &ealt&;int a6e;public:player() { &ealt&=Q; a6e=1Q } ,,/onstructor1player(int int a) {&ealt& =&; a6e = a ; } ,,/onstructor$player( player Op) { } ,,/onstructor2~player() { cout
7/26/2019 Constructor Assignment C++
4/4
ob16m-.or();
"
vii) 5ic %eature o% ob3ect oriente! programming is !emonstrate! using Function #' Function * an!
Function , in te above class testmeout4
viii) 5at is te scope o% !ata member (rollno) o% class testmeout4 5at !oes te scope o% !ata members
!epen! upon4
88888888888888888888988888888888888888888988888888888888888888888888898888888888888888888898888888888888888