点滴知识01-----能够返回数组的函数

来源:互联网 发布:超级奇门遁甲排盘软件 编辑:程序博客网 时间:2024/06/06 08:55
一个可以返回数组的函数编写:
#include   <iostream> 
#include   <string>

using namespace std;


int *ABC(int c,int d,int w)
{
    int *a=new int[3];
    a[0] = c;
    a[1] = d;
    a[2] = w;

    return a; // before this statement, no delete []a!
}
int main() 
{
    int *b = new int[3];
    b = ABC(2,3,4);
    cout << b[2] << endl;
    return 0;



虽简单,但还是有一定价值的。
原创粉丝点击