指针数组

 1 #include <iostream>
 2 using namespace std;
 3 double* aaa()
 4 {
 5     double tmp[3] = { 1.0,2.0,3.0 };
 6     double* tmp1 = new double[3];
 7     for (size_t i = 0; i < 3; i++) tmp1[i] = tmp[i];
 8     return tmp1;
 9 }
10 
11 
12 int main()
13 {    
14     double* a = new double[3];
15     a = aaa();
16     for (size_t i = 0; i < 3; i++)
17     { 
18         cout << *(a+i) << endl; 
19     }
20     delete[]a;
21     system("pause");
22 }

 

posted @ 2021-02-27 20:41  老婆饼里有老婆  阅读(60)  评论(0编辑  收藏  举报