Skip to content

Instantly share code, notes, and snippets.

Created July 16, 2015 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a8faec72cb1423261c86 to your computer and use it in GitHub Desktop.
Save anonymous/a8faec72cb1423261c86 to your computer and use it in GitHub Desktop.
#include <string>
int main()
{
std::string *sp = new std::string("hehe");
sp->~string();//expected class-name before ‘(’ token
operator delete (sp);
return 0;
}
//----------file1-----------
#include <string>
using std::string;
int main()
{
string *sp = new string("hehe");
sp->~string();//通过
operator delete (sp);
return 0;
}
//--------file2---------
struct Ints {
int ival;
int ival1;
};
int main()
{
Ints* p = new Ints{1,2};
p->~Ints();
operator delete (p);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment