我通过Add Files将GLM目录添加到"project_name",然后添加:#include "glm.hpp"在main.cpp中,在编译期间我遇到了以下错误.
几天前我开始使用 OOP,所以我没有经验。我想知道是否有机会更改类属性的值以影响使用该类的所有对象?
例子:
function Balloon(ID){
this.ID = ID;
this.speed = 1;
}
Run Code Online (Sandbox Code Playgroud)
假设我有 5 个 Balloon 对象。现在我想在不使用 for 循环的情况下将所有速度值更改为 2。
将创建的表传递给fillMatrix函数时遇到问题.另一件事是如何在我的函数中引用这个表.我非常感谢各种帮助.我没有得到任何控制台问题.计划冻结了.
int **createTable(int n)
{
int **table = new int*[n];
for(int i = 0; i<n; i++)
{
table[i] = new int[n];
}
return table;
}
void fillMatrix(int n, int **tab)
{
for(int x = 0; x<=n; x++)
{
for(int y= 0; y<=n; y++)
{
tab[x][y] = 0;
}
}
}
int main()
{
int n;
cout <<"Add size of table";
cin >> n;
int **table = createTable(n);
srand(time(NULL));
fillMatrix(n, table);
return 0;
}
Run Code Online (Sandbox Code Playgroud)