There are no pointer (anymore?) in Galaxy. We got a partial replacement with structrefs, funcref and arrayrefs, which are references to their respective elements. Note that you cant use any *ref types as return value in functions.
Hello, try removing the "*" from "int* b". Like this:
void nevermind()
{
int a = 1;
int b = &a;
}
Pointers point to addresses, &a is an address to memory, if you say "*b = &a" you're saying put the address of "a" to the content of "b" which is wrong and the compiler will be upset about it. If you put "b = &a" you're saying point b towards whatever address of memory is a at. Hope it helps!
I suggest you revisit pointers. The code you posted does not do what you think it does (it will actually cause a decent C compiler to complain about type mismatch).
But all of this is moot, because Galaxy doesnt support pointers. The closest you can get is what JademusSreg posted.
Hello everyone,
i need to ask something (maybe) stupid. i try to set a pointer (like in many examples or cpp). But the syntax seems to be changed.
For example:
Will throw a syntax error at ("int* b= &a;").
i would be glad if someone can explain how to realize. I saw something about structs (<structref>) maybe this is my fault.
Sincerely yours,
Inqui
There are no pointer (anymore?) in Galaxy. We got a partial replacement with structrefs, funcref and arrayrefs, which are references to their respective elements. Note that you cant use any *ref types as return value in functions.
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
I supposed that :( BUT anyway, you give me the right direction to find another solution, thanks for that :)
Kind regards,
Inqui
Pointers were removed in SC2 WoL beta patch 9.
Instead, one may do something like this:
Not ideal, but effective.
I will forever love Jade's func/var names.
@Inquisito: Go
Hello, try removing the "*" from "int* b". Like this:
void nevermind() { int a = 1; int b = &a; }
Pointers point to addresses, &a is an address to memory, if you say "*b = &a" you're saying put the address of "a" to the content of "b" which is wrong and the compiler will be upset about it. If you put "b = &a" you're saying point b towards whatever address of memory is a at. Hope it helps!
@joemart06: Go
I suggest you revisit pointers. The code you posted does not do what you think it does (it will actually cause a decent C compiler to complain about type mismatch).
But all of this is moot, because Galaxy doesnt support pointers. The closest you can get is what JademusSreg posted.
@Deaod: Go
You're right, here this one should work now:
void nevermind() {
int a = 1;
int *b; pointer to int
b = &a; pointer now points to address in memory
cout << *b << endl << a;
/* Output: 2 2
}