Advertisement

array bag

Started by September 19, 2011 01:14 PM
4 comments, last by WitchLord 13 years, 5 months ago
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()"
Don't you need to override DO in your child class in order for B's DO method to be called?

Remember to mark someones post as helpful if you found it so.

Journal:

http://www.gamedev.net/blog/908-xxchesters-blog/

Portfolio:

http://www.BrandonMcCulligh.ca

Company:

www.gwnp.ca

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

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
[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"];
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement