Jump to content
  • Advertisement
Sign in to follow this  
FDsagizi

array bag

This topic is 2643 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

hello!
I find bug in standart addon array<>

code:

class A{

void DO(){

output( "A::DO()" );

}

}



class B : A{

void DO(){

output( "B::DO()" );

}

}

B b;
array<A> arr;
arr.insertLast( b );
arr[0].DO();





this script show "A::DO()"

Share this post


Link to post
Share on other sites
Advertisement

All functions are virtual in angelscript, so the override is implicit.


Yes, [color=#333333][font=arial, sans-serif][size=2]smile.gif[/font]
[font="arial, sans-serif"][color="#333333"]
[/font]


[color=#333333][font=arial, sans-serif]And this script is not running correctly, it should return "[/font][color=#008800][font=CourierNew, monospace][size=2]B::DO()[/font][color=#333333][font=arial, sans-serif][size=2]" but, he returned "[/font][color=#008800][font=CourierNew, monospace][size=2]A::DO()[/font][color=#333333][font=arial, sans-serif][size=2]" - that is wrong, and very serious![/font]sad.gif

Share this post


Link to post
Share on other sites
[color="#333333"][font="arial, sans-serif"]oh, I beg your pardon! It's my fault, it was necessary to do so:[/font]
[color="#333333"][font="arial, sans-serif"] [/font]
[color="#1C2837"][color="#000000"]array[color="#666600"]<[color="#000000"]A[color="#666600"]>[color="#000000"] arr[color="#666600"];
[color="#666600"]

[color="#1C2837"][color="#666600"]ok:
[color="#1C2837"][color="#000000"]array[color="#666600"]<[color="#000000"]A[size="5"]@[color="#666600"]>[color="#000000"] arr[color="#666600"];

Share this post


Link to post
Share on other sites
I thought you had come up with a new concept when I saw the forum topic 'array bag', as in 'bag of arrays' ;)


You're right, the first example would make a copy of the object when 'b' is assigned to the array element, so the element would really be of the type 'a'.


This is one of the main reasons why I'm planning to go the java way in version 3.0, where all reference types are treated by handles implicitly. Then these mistakes cannot happen anymore. However, version 3.0 is very far away. There is still a lot to improve on version 2.x before I can officially start working on version 3.0.

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!