So in C# I can create an array of n elements:

int[] myArray = new int[n];

I have looked and it doesn't seem as though I can create an array like this in C++ (using new).

Could anyone please explain why I cannot use new to create an array in C++?

Recommended Answers

All 2 Replies

Look up any tutorial on the c++ concept of 'dynamic arrays'

int* myArray = new int[n];

Ok thanks, so the difference is that you just have to explicitly create the pointer in c++?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.