Jump to content
  • Advertisement
Sign in to follow this  
cosmicdust

Object handle help!

This topic is 2782 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi,

I get error when build this code:



IndicatorOutputStream@ outStream = null;
void Fun()
{
outStream = getOutputStream();
}

or


IndicatorOutputStream@ outStream2 = null;
void Fun()
{
IndicatorOutputStream@ outStream = getOutputStream();
outStream2 = outStream;
}

the error is :


ERR : No default constructor for object of type 'IndicatorOutputStream'.
ERR : There is no copy operator for this type available.
ERR : There is no copy operator for this type available.
Please correct the errors in the script and try again.

But if code this, build is ok


void Fun()
{
IndicatorOutputStream@ outStream = getOutputStream();
}

what's the differenc between the two code style?
I thank object handle as the c++ pointer, but c++ pointer = don't need copy operator, I'm confused about object handle

wish some help, thanks!

Share this post


Link to post
Share on other sites
Advertisement
Hi

To assign handle with new object you need to use @ before variable name, like
[color=#1C2837][size=2]@outStream = getOutputStream();
[color=#1C2837][size=2]AS handles are more like references than pointers, simple assignment will work object itself not on handle.
[color=#1C2837][size=2]

[color=#1C2837][size=2](in fact this is my most common source of errors, and since my c++ ref types never have opAssign, I really don't like/need that feature. I did some research with implicit handles and made quick path for all reference types, but it didn't play well with script defined types (they are always ref types))
[color=#1C2837][size=2]

Share this post


Link to post
Share on other sites
It's ok now, thanks :)

Hi

To assign handle with new object you need to use @ before variable name, like
[color="#1C2837"]@outStream = getOutputStream();
[color="#1C2837"]AS handles are more like references than pointers, simple assignment will work object itself not on handle.
[color="#1C2837"]
[color="#1C2837"](in fact this is my most common source of errors, and since my c++ ref types never have opAssign, I really don't like/need that feature. I did some research with implicit handles and made quick path for all reference types, but it didn't play well with script defined types (they are always ref types))
[color="#1C2837"]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!