[try Beta version]
Not logged in

 
 
one more const problem !?

Nov 5, 2011 at 5:24am
it says:
"expression must be constant value"
"can't create an array of size 0"

1
2
3
4
5
int main() {
	const int* const var = new const int(30);
	int arr [var];
	return 0;
}

Nov 5, 2011 at 5:53am
Why are you using a pointer to set the length of your array?

-Albatross
Nov 5, 2011 at 7:32am
1
2
3
4
5
int main() {
	const int* const var = new const int(30);
	int arr [*var];
	return 0;
}

On some compilers it would even work.
Nov 5, 2011 at 12:13pm
tnx for replys...
On some compilers it would even work.

well it doesn't work on my compiler:
1
2
3
4
5
int main() {
	const int* const var = new const int(30);
	const int arr [*var];
	return 0;
}


Why are you using a pointer to set the length of your array?

acctualy I'm not, I just wanna know why that's impossible?
altrough value is constant and valid.
Nov 5, 2011 at 12:32pm
To dereference the pointer, you need to know its address, but it would be given to it only after the program have started, but the demension of the array must be the compile-time-constant.
Nov 5, 2011 at 2:19pm
Ohh! lol
off course :D

thanx for clarification Syuf!!
Topic archived. No new replies allowed.