0

Why to write "new" after the assignment operator?

4th Nov 2018, 4:44 PM
Yash Paneliya
4 Respostas
+ 2
When you see: People p = new People(); In the right side of expression. I'm instantiating a object calling the defined constructor in class People. In the left side i'm declaring the variable tha will store this object. When im using new i'm saying to "create" a new object of determinate type.
4th Nov 2018, 5:27 PM
Anya
Anya - avatar
+ 2
"New" operator is used to dinamically allocate memory of variable size which is situated on the right from the operator. It will return pointer to allocated memory.
4th Nov 2018, 5:27 PM
microBIG
microBIG - avatar
+ 2
this depends on the language. new in c++ is completely different from new in other languages such as c#
4th Nov 2018, 6:13 PM
Jordan Chapman
Jordan Chapman - avatar
+ 2
Jordan Chapman True. i just supposed that was java related by the courses progress Yash Paneliya has.
4th Nov 2018, 6:17 PM
Anya
Anya - avatar