[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

using pointer to pointer(**

Tony Johansson

12/7/2008 4:36:00 PM

Hello!

I have noticed that if you want to return an object from a method the
example
I have seen always use **.

Can somebody explain why?

//Tony


3 Answers

Paavo Helde

12/7/2008 4:51:00 PM

0

"Tony Johansson" <johansson.andersson@telia.com> kirjutas:

> Hello!
>
> I have noticed that if you want to return an object from a method the
> example
> I have seen always use **.
>
> Can somebody explain why?
>

Seems like C code or unjustified premature optimization attempts. In C++
the simplest way to return an object from a function would be:

class A {/*...*/};

A f() {
return A();
}

int main() {
A a1 = f();
}

RVO technigues used by many compilers might easily yield better
performance here than with dynamic allocation and pointer-to-pointer
hacks.

Paavo







Andrey Tarasevich

12/7/2008 5:57:00 PM

0

Tony Johansson wrote:
> I have noticed that if you want to return an object from a method the
> example
> I have seen always use **.
>
> Can somebody explain why?

You need to provide an example of what you are talking about. So far It
doesn't make much sense.

--
Best regards,
Andrey Tarasevich

Jobin Paul

12/8/2008 12:50:00 PM

0

Same opinion as of Andrey.

It doesn't make much sense without the example.

In C++ whatever you return are objects.

int A()
{
return 10; // if you are still doubt use return int(10);, i mean
call the integer contructor explicitly
}

this returns an object of type int.

there is no ** here ( not even *)