Visual c++ 定义函数返回二维数组

专栏 / Visual c++ 定义函数返回二维数组

Visual c++ 定义函数返回二维数组

2022年12月17日 12:24 --浏览 · --点赞 · 焚香落烬
粉丝: 24 文章: 15


源文件中的函数定义代码
头文件中的函数声明
源文件中主函数的代码

主函数:

#include<iostream>

#include"12.17erweishuzu.h"

using namespace std;


int main()

{

double (*qwe)[10];

qwe= erwei(2.2, 1);

for (int i = 0; i < 10; i++)

for (int j = 0; j < 10; j++)

cout << qwe[i][j] << endl;


cout << endl;


cout << qwe << endl;

cout << erwei << endl;

return 0;

}

源文件,函数定义代码:

#include<iostream>

#include"12.17erweishuzu.h"

using namespace std;


double(*erwei(double t, int x))[10]

{

double(*high)[10] = new double[10][10];

for (int ii = 0; ii < 10; ii++)

{

for (int jj = 0; jj < 10; jj++)

{

high[ii][jj] = ii * 10 + jj;

}

}

return high;

}


头文件,函数声明:

#pragma once

#include<iostream>

using namespace std;

//函数的声明

double(*erwei(double t, int x))[10];