C++ Question

I

ImageConsultant

Please give the ans. to the following question :-
Q 1 Write a class which always allocate memory to its objects from heap only?

Warms Regards,
Madhur Sharma
 
R

Rolf Magnus

ImageConsultant said:
Please give the ans. to the following question :-
Q 1 Write a class which always allocate memory to its objects from heap
only?

This is not a question, it is an assignment. Looks like homework to me. The
deal is to show us what you have and what doesn't seem to work, and we give
you advice on how to make it work.

PS: Next time, you should be a bit more specific in your subject line. In
this newsgroup, we expect an initial posting to be a C++ question. That's
what comp.lang.c++ is all about.
 
P

Phil Staite

ImageConsultant said:
Please give the ans. to the following question :-
Q 1 Write a class which always allocate memory to its objects from heap only?

Here's a hint - consider hiding the constructor(s) and providing a
static method to generate an instance...
 
M

Mr Hand

Please give the ans. to the following question :-
Q 1 Write a class which always allocate memory to its objects from heap only?

Why?

If you feel the class has too big a sizeof() to put on the stack then
just include that information in the documentation.

Otherwise there is no difference if an object is allocated on the heap
or in the stack.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top