我一直在努力解决这个问题。我进行了全面搜索,似乎发现的都是带有相同错误消息的问题,但涉及构建完整的iPhone应用程序或处理头文件等各种问题。
我只是在编写一个简单的C ++程序,除了典型的iostream,stdlib.h和time.h外没有头文件。这是用于非常简单的大学作业,但是我无法继续工作,因为Xcode给出了与实际代码无关的错误(基于我所阅读的内容)。除了实际的.cpp文件之外,我没有其他任何混乱,我什至不知道如何将其弄乱。我已经以相同的方式完成了多项任务,并且从未遇到过这个问题。
当前代码:
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
//functions
void funcion1(int matriz, int renglones, int columnas);
void funcion2(int matriz, int renglones, int columnas);
//variables
int renglones=8;
int columnas=8;
int ** matriz = new int*[renglones];
int main()
{
//reservar columnas
for (int i=0; i < renglones; i++)
{
matriz[i] = new int[columnas];
}
srand(time(NULL));
funcion1(**matriz, renglones, columnas);
funcion2(**matriz, renglones, columnas);
}
void funcion1(int **matriz, int renglones, int columnas)
{
for (int y = 0; y <= renglones; y++)
{
for (int x = 0; x <= columnas; x++)
{
matriz[y][x] = rand() % 10;
}
}
}
void funcion2(int **matriz, int renglones, int columnas)
{
for (int y = 0; y <= renglones; y++)
{
for (int x = 0; x <= columnas; x++)
{
cout << matriz[y][x] << " ";
}
cout << "\n";
}
}
错误屏幕截图
编辑:下面的固定代码。
void funcion1(int **matriz, int renglones, int columnas)
{
for (int y = 0; y < renglones; y++)
{
for (int x = 0; x < columnas; x++)
{
matriz[y][x] = rand() % 10;
}
}
}
void funcion2(int **matriz, int renglones, int columnas)
{
for (int y = 0; y < renglones; y++)
{
for (int x = 0; x < columnas; x++)
{
cout << matriz[y][x] << " ";
}
cout << "\n";
}
}
您没有向链接器提供funcion1(int, int, int)
和funcion2(int, int, int)
功能。您正在main()程序中调用它们,但是链接器找不到它。
不,这不会调用您的funcion1(int**, int, int)
函数:
funcion1(**matriz, renglones, columnas);
您将int**
在两个级别上取消引用,从而产生一个int
。您对的致电也是如此funcion2
。
调用funcion1(**matriz, renglones, columnas)
函数:
funcion1(matriz, renglones, columnas);
同样的事情 funcion2(int **, int, int);
funcion2(matriz, renglones, columnas);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句