64,662
社区成员
发帖
与我相关
我的任务
分享
int main()
{
{
string *p=new string;
*p="test";
delete p;
}
{
string *p=(string*)malloc(sizeof(string));
new (p) string;
*p="test";
free(p);
}
return 0;
}
struct StuNode
{
string name;
float score;
};
class ScoreMngt
{
private:
int len;
StuNode *student;
public:
ScoreMngt();
};
ScoreMngt::ScoreMngt()
{
len=10;
student=new StuNode[len+1];
//student=(StuNode*)malloc((len+1)*sizeof(StuNode));
if(!student)
exit(-1);
student->name="赵本山";
student->score=59.9;
student++;
}
int main()
{
ScoreMngt sm;
return 0;
}