template<class A,class B>
void tmp(){
set<int,int>::iterator it; //works
set<A,B>::iterator it; // doesn't work
}
Run Code Online (Sandbox Code Playgroud) int _tmain(int argc, _TCHAR* argv[])
{
char* myArr = new char[5];
cout << strlen(myArr) << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么打印出12(而不是5)?
编辑:添加myArr [ 5 ] ='\ 0'; 解决了这个问题.但它需要的记忆不是我的.这可以吗?
c++ ×2