Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
If I have:
int **p;
why can't I do this?
p = new *int[4];
but if I have:
class T {...} T **c; c = new *T[4];
is that correct?
The * has to come after the type-name that it modifies:
*
p = new int*[4]; c = new T*[4];
Add a comment
No it is not correct.
the * must go after the type-name.
Then it should be:
p = new int*[4];
And
c = new T*[4];
You're trying to multiply the keyword new with the type (int or T)! To say you want a new array of pointers to int:
new
int
T
or an array of pointers to T:
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.