It's not "int var[1];" that is causing the problem - this is variable declaration, and this is fine. The problem is in "arr[0]=1;" - this assignment is program code that cannot be executed outside of the function.
Shoutbox archive
I've been working on my Code Battle program again. I've got multiple variables within and outside of the constructor. I just wanted to get an array there and can't get that to work. Why would "int var[1];" work different than "int var;? Double standard?
Because this code doesn't make any sense, put that arr[0]=1; into a method, preferably constructor.
@krzys_h I did switch to the dev via the link you provided but the issue is still there. The folowing code does not compile: "public class cls { int arr[1]; arr[0]=1; }" The error displayed is nonsensical: "type declaration missing" on line "arr[0]=1" .
Has something happened to our forum security? I've just deleted a second spammer from the last 2 weeks. The first one at least was a little bit original, it posted a link in Shoutbox.
@krzys_h I'm gonna switch to the latest dev and check. I still use 0.1.7b at the moment.
Colonize With Bots - Rise of the Planet of the Alien Insects 3: Reassembled Director's Cut Edition
Ah, silly people... How many times do I need to tell ya that the only proper, official way to write those names is cOlObOt and c-Bot?
@Mrocza possibly fixed on latest dev in https://github.com/colobot/colobot/commi...8916729e63 , if it still doesn't work give an exact program code as the unit test for arrays in classes seems to work correctly
assuming this is from that code fragment, there might be another overflow somewhere else
@Adikso that buffer overflow should be already fixed in latest dev version https://github.com/colobot/colobot/commi...a52f2d2219
I prefer to use CBot, I use C-Bot to refer to original game, not language.