V
Victor Bazarov
Maximus said:I'd like to know if it's possible to allocate a multidimensional array
during runtime using the new operator.[...]
Take a look at the FAQ. Section 16, question 16.15.
Maximus said:I'd like to know if it's possible to allocate a multidimensional array
during runtime using the new operator.[...]
Maximus said:I'd like to know if it's possible
to allocate a multidimensional array at run-time
using the new operator.
g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)g++ --version
#include <iostream>cat main.cc
main.cc: In function `int main(int, char**)':g++ -Wall -ansi -pedantic -o main main.cc
Hello World!./main 3 4
Hi,
I'd like to know if it's possible to allocate a multidimensional array
during runtime using the new operator.
Maximus said:I'd like to know if it's possible
to allocate a multidimensional array at run-time
using the new operator.
No. But my GNU C++ compiler
g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)g++ --version
will create variable-size arrays:
> cat main.cc
#include <iostream>
int main(int argc, char* argv[]) {
const int m = atoi(argv[1]);
const int n = atoi(argv[2]);
int test[m][n];
std::cout << "Hello World!" << std::endl;
return 0;
}
main.cc: In function `int main(int, char**)':g++ -Wall -ansi -pedantic -o main main.cc
main.cc:6: warning: ISO C++ forbids variable-size array `test'
main.cc:6: warning: ISO C++ forbids variable-size array `test'
main.cc:6: warning: unused variable `int test[m][n]'Hello World!./main 3 4
Variable-size arrays were recently
introduced into the ANSI/ISO C 99 standard.
Are they part of the ANSI/ISO C++ 2003 standard?
Are they part of the ANSI/ISO C++ 2003 standard?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.