/* New and delete operator in C++ */ #include "iostream" using namespace std; int main(){ int *p=new int; *p = 10; cout<<"\n*p: "<<*p; float *q = new float; *q = 20.05; cout<<"\n*q: "<<*q; int n=3; cout<<endl; int *r = new int[n] ; for(int i=0; i<n; i++){ q[i] = i+1; cout<<q[i]<<endl; } } /* OUTPUT [pavan@localhost Unit-2-Inheritance]$ g++ NewDelete.cpp [pavan@localhost Unit-2-Inheritance]$ ./a.out *p: 10 *q: 20.05 1 2 3 [pavan@localhost Unit-2-Inheritance]$ */
The Tech Zone is built to promote open source technologies. Hadoop, Linux Administration, Cloud, Java Technologies, Operating Systems, Advanced Computer Programming, etc are the key areas of focus. Computer and IT engineering students can find important study material on this portal.
Thursday, 21 September 2017
New and delete operator in C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment