+ 3

Wrong C++ Challenge Question

I keep flagging this question, but the developers don't do anything about it... It's absurd. The first option is also perfectly valid. https://cernbox.cern.ch/s/eWuVNHfkKmQIPZy

19th Dec 2022, 11:12 PM
Edward Finkelstein
Edward Finkelstein - avatar
4 Réponses
+ 2
@Mishu. The First option, is declaring an integer pointer int* arr; which, as you know, stores the address of an integer variable. The first option then assigns this integer pointer an address in memory somewhere on the heap. int* arr = new int; The value stored at that address in heap memory currently being stored by our integer pointer arr is 0, as you can see by the following line: cout << *arr; //outputs 0 So this is perfectly valid. If you wanted to have the default value be something else, 5 for example, you would do: int *arr = new int(5); then: cout << *arr; //outputs 5 I understand that the name of the variable, 'arr', inclines one to think that this pointer will store the heap address of the first element of a sequence of values, i.e., array, but still the question needs to be rephrased. I hope I have effectively communicated why I think there is a problem with this question.
20th Dec 2022, 4:37 PM
Edward Finkelstein
Edward Finkelstein - avatar
+ 2
Regarding this comment: Um isn't it from outer source, means out of Sololearn? Why have you posted? To share your feelings or just to inform us, or make a protest against it? This is actually from a Sololearn challenge that I was doing on an Ipad. To preserve the privacy of the other player, I black the name out. Hopefully, this image shows that better: https://cernbox.cern.ch/s/WQaPQVYSLcpcOkS I made this post because I don't think it's right to have this question the way it is, especially on such a platform. But I don't expect anything from making this post; it's not within my control. But any resolution would certainly be welcome.
20th Dec 2022, 4:59 PM
Edward Finkelstein
Edward Finkelstein - avatar
+ 1
Um isn't it from outer source, means out of Sololearn? Why have you posted? To share your feelings or just to inform us, or make a protest against it?
20th Dec 2022, 2:53 PM
Mishu
Mishu - avatar
+ 1
The First Option is not correct, because when you declare a new array type, you must declare its data holding capacity / size. So the second option is only correct. Don't flag it as incorrect.
20th Dec 2022, 2:56 PM
Mishu
Mishu - avatar