[Cpp-Programming] Re: doubt in c++
Hi,
square obj_sqr1;
- By this way, you can create an object at compile time i.e. when program gets compiled, memory is allocated for obj_sqr1. It's static allocation.
The other way is runtime/dynamic allocation/creation.
But I found this site which confused me too:
http://www.codeguru.com/forum/archive/index.php/t-250505.html
Now my question to group is: Is it true dynamic creation is not supported directly by the C++ language."
Regards,
Niketa
On Thu, Jul 30, 2009 at 9:51 PM, cooldude <srivatsak.s@gmail.com> wrote:
hi,
i'm pretty new to c++. i have got a simple doubt. please answer.
i have a class called square.
class square
{
//some implementation here
}
now when i write the main program i create the object. here is where
i'm confused. i feel i can create the object square in two ways. let
me know if i'm correct.
square obj_sqr1; // this is one way
square* ptr_square;
ptr_square = new square ; // using the new operator, forgive me if
the syntax is wrong
what is the difference between the two ? are they same ? ..
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---
0 Comments:
Post a Comment
<< Home