你知道你想做什么吗?
是想打印Hi,earth
还是想创建一个字符串然后再打印Hi,earth呢?
是想打印Hi,earth
还是想创建一个字符串然后再打印Hi,earth呢?

把学习时间浪费在混坛上是傻瓜行为,更何况自己的水平连一两都没到。
2020-03-30 14:30
程序代码:#include <iostream>
#include <algorithm>
#include <vector>
#include <memory>
using namespace std;
int main( void )
{
size_t n;
if( !(cin>>n) )
return 1;
// 方法一
vector<int> a( n );
cout << a[0] << endl;
// 方法二
std::unique_ptr<int[]> b( new int[n]{} );
cout << b[0] << endl;
}
2020-03-30 14:30
2020-03-30 15:56
2020-03-30 16:10
2020-03-30 16:13