Gentlemen,
Is it possible to initialize the array at the time of creation??
I mean:

int *a = new int[10]; // here array is only created. I wanna initialize the same too here itself. Is it possible???

Comments
Start your own thread for this

Why neg him, he is learning. WTF.

int a [10]= [1,2,3,8,7,19,15,555,1024,12458]

Peace

WTF

Read the comment. He had tacked this onto another thread. It was assessed in that thread and after that it was split off by a moderator.

Edited 6 Years Ago by jonsca: n/a

I don't see no comment

You click the : "Add and View Reputation Comments" link next to the orange dot to see the reputation comment.
And Jonsca is right. This post was originally piggybacked on another thread when I split it.

@coded_hitec: With what values do you want to "initialize" the array?

Comments
Got it all squared away over PM :)

Why neg him, he is learning. WTF.

int a [10]= [1,2,3,8,7,19,15,555,1024,12458]

Peace

Sir,
I am asking is it possible to initialize a array which is created dynamically using new operator

umm? sorry u need to use curly brackets

int *a = {1,2,3,8,7,19,15,555,1024,12458}

you can substitute the values with variables.

My C++ is rather old but this should work.

>> My C++ is rather old but this should work.
Sorry but that will not work either. Consider compiling the code that you post. Even if you are posting minimal snippets/one-liners.

@coded_hitec I believe the answer to your question is "no" but I would be happy to be corrected.

Yeah,
I checked it out at various sources and the answer is no only

thanks for your efforts sir

This question has already been answered. Start a new discussion instead.