Menu

Custom Search

C++ lab Program

/* justify the o/p of the following program*/
#include
#include

class numlist {
int*ptr;
int n;

public:
numlist(int x){
n=x;
ptr=new int[n];
cout<<"Dynamic memory allocatin with constructors\n:"; } void input(){ cin>>n;
cout<<"input "<>ptr[i];
}
void display(){
cout<<"the list:"< for(int i=0;i cout<<"ptr["< }
~numlist(){
cout<<"destructors with delete operator"< delete []ptr;
}
};

int main(){
numlist z(5);
z.input();
z.display();
getch();
return 0;
}

/*
o/p:-
Dynamic memory allocation ith constructors
:1
input 1 integer:
2
the list:
ptr[0]=2
*/

No comments:

Post a Comment