new&delete示范运用

new&delete示例运用#include iostream#include stringusing namespace stdstruct student{ int num

new&delete示例运用
#include <iostream>
#include <string>
using namespace std;
struct student
{
 int num;
 string name;
 string sex;
};
int main()
{
 student*p;
 p=new student;
 p->num=110;
 p->name="陆岩";
 p->sex="男";
 cout<<p->num<<endl<<p->name<<endl<<p->sex<<endl;
 delete p;
 return 0;
}