Nov 05 2011 07:50 AM 15350 8 What are the different way of creating object in c++ ? vikas kushwah NikunjSingh Profile Answers by NikunjSingh Questions by NikunjSingh Feb 23rd, 2012 1. using normal object creation: Shape obj; 2. copy ctor: Shape obj2=obj;// or Shape obj3(obj); 3. using new operator;Code#include <iostream> using namespace std; class Shape{ public: Shape(){cout<<"Shape..."<<endl;} Shape(const Shape& obj) { cout<<"Copy called"<<endl; } void* operator new(size_t size) { cout<<"new...."<<endl; void* storage=malloc(size); if(NULL == storage) { throw "allocation fail : no free memory"; } return storage; } void operator delete (void*){ } }; int main() { Shape obj; Shape obj2=obj; Shape obj3(obj); Shape* ptrShape=new Shape(); Shape* ptrShapeOver= new Shape(); return 0; } Isaac Feb 21st, 2012 1. Create on stack. i.e. ClassA varA; 2. Create on heap. i.e. ClassA *ptrA = new ClassA; Answer Question Select Best Answer Oct 15 2011 08:23 AM 3937 2 How do you find the size of the Object in Java ? vikas kushwah Lokesh M Profile Answers by Lokesh M Questions by Lokesh M Nov 28th, 2011 You can make use of getObjectSize function to find size of the Object. Codelong getObjectSize(Object objectToSize) Answer Question Select Best Answer Sep 20 2011 11:10 AM 10394 16 C++ without Header files vikas kushwah How we can run our c++ program without header files? Eric Nantel Apr 23rd, 2015 Put everything in the only cpp containing main() harshit Apr 14th, 2015 We can run c++ program without using header files by making the definition of all the functions and keywords in the programs Answer Question Select Best Answer
Nov 05 2011 07:50 AM 15350 8 What are the different way of creating object in c++ ? vikas kushwah NikunjSingh Profile Answers by NikunjSingh Questions by NikunjSingh Feb 23rd, 2012 1. using normal object creation: Shape obj; 2. copy ctor: Shape obj2=obj;// or Shape obj3(obj); 3. using new operator;Code#include <iostream> using namespace std; class Shape{ public: Shape(){cout<<"Shape..."<<endl;} Shape(const Shape& obj) { cout<<"Copy called"<<endl; } void* operator new(size_t size) { cout<<"new...."<<endl; void* storage=malloc(size); if(NULL == storage) { throw "allocation fail : no free memory"; } return storage; } void operator delete (void*){ } }; int main() { Shape obj; Shape obj2=obj; Shape obj3(obj); Shape* ptrShape=new Shape(); Shape* ptrShapeOver= new Shape(); return 0; } Isaac Feb 21st, 2012 1. Create on stack. i.e. ClassA varA; 2. Create on heap. i.e. ClassA *ptrA = new ClassA; Answer Question Select Best Answer
NikunjSingh Profile Answers by NikunjSingh Questions by NikunjSingh Feb 23rd, 2012 1. using normal object creation: Shape obj; 2. copy ctor: Shape obj2=obj;// or Shape obj3(obj); 3. using new operator;Code#include <iostream> using namespace std; class Shape{ public: Shape(){cout<<"Shape..."<<endl;} Shape(const Shape& obj) { cout<<"Copy called"<<endl; } void* operator new(size_t size) { cout<<"new...."<<endl; void* storage=malloc(size); if(NULL == storage) { throw "allocation fail : no free memory"; } return storage; } void operator delete (void*){ } }; int main() { Shape obj; Shape obj2=obj; Shape obj3(obj); Shape* ptrShape=new Shape(); Shape* ptrShapeOver= new Shape(); return 0; }
Isaac Feb 21st, 2012 1. Create on stack. i.e. ClassA varA; 2. Create on heap. i.e. ClassA *ptrA = new ClassA;
Oct 15 2011 08:23 AM 3937 2 How do you find the size of the Object in Java ? vikas kushwah Lokesh M Profile Answers by Lokesh M Questions by Lokesh M Nov 28th, 2011 You can make use of getObjectSize function to find size of the Object. Codelong getObjectSize(Object objectToSize) Answer Question Select Best Answer
Lokesh M Profile Answers by Lokesh M Questions by Lokesh M Nov 28th, 2011 You can make use of getObjectSize function to find size of the Object. Codelong getObjectSize(Object objectToSize)
Sep 20 2011 11:10 AM 10394 16 C++ without Header files vikas kushwah How we can run our c++ program without header files? Eric Nantel Apr 23rd, 2015 Put everything in the only cpp containing main() harshit Apr 14th, 2015 We can run c++ program without using header files by making the definition of all the functions and keywords in the programs Answer Question Select Best Answer
harshit Apr 14th, 2015 We can run c++ program without using header files by making the definition of all the functions and keywords in the programs