1

in c# I can do this:

private double[,] elevations;

How to do the same in c++ without specifying the size or elements of array on this line?

2
  • 2
    For dynamically sized arrays, use std::vector Commented Mar 13, 2015 at 3:48
  • @onsmith no you can't Commented Mar 13, 2015 at 4:15

1 Answer 1

5

You cannot do that for arrays in C++.
But, if you want dynamic size, go for std::vector.

And from your question, I see that you are interested in a 2D array. Hence, use a nested std::vector, like this:

vector< vector< double > > elevations;
Sign up to request clarification or add additional context in comments.

2 Comments

A vector of vector<double>s.
@DonLarynx Exactly. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.