#include <iostream> using namespace std; double* aaa() { double tmp[3] = { 1.01,2.02,3.03 }; double* tmp1 = new double[3]; for (size_t i = 0; i < 3; i++) tmp1[i] = tmp[i]; return tmp1; } int main() { double* a = new double[3]; a = aaa(); for (size_t i = 0; i < 3; i++) { cout << *(a + i) << endl; } delete[]a; system("pause"); }
运行结果:
1.01
2.02
3.03
请按任意键继续. . .