I stumbled across this piece of code, and could not understand how the new operator was used in this case:
student* setname(string name)
{
student* stu=(student*)malloc(sizeof(student));
new(stu) student;
stu->age=12;
stu->name=name;
return stu;
}
I would expect new to be used like stu = new student;. How is new(stu) student different?