one more const problem !?

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;
}

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

-Albatross
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.
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.
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.
Ohh! lol
off course :D

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