[Cpp-Programming] Re: doubt in c++
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
> {
void sum();
> //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 ? ..
ans: their internal representation in the memory is same
but when we code thier syntax is very different.
say e.g when calling a member function
square obj;
square *ptrobj;
ptrobj=new square();
obj.sum();
ptrobj->obj();
--~--~---------~--~----~------------~-------~--~----~
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