class Cexample{
public:
virtualint example();
int xyLoc[50][25];
private:
i, j;
};
int Cexample::example()
{
for(i = 34; i<46; i++){
for(j=3; j<23; j++){
if(i < 35 || i > 44){
xyLoc[i][j] = 1;
}
elseif(((i>34 && i<45))&&(j<4 || j>21))
xyLoc[i][j] = 1;
}//end for
}//end for
xyLoc[37][15] = 1;
xyLoc[38][13] = 1;
xyLoc[39][14] = 0;
}
void deleteLoc()
{
CExample ex;
ex.xyLoc[37][15] = 0; //heres the problem, xyLoc[37][15] doesn't change its
//value, it is still 1,
//so the function called by main cannot change the
//value of the function of a class? What is the proper
//way of changing the value of the function of the
//class? using the function called by main.
}
int main(){
deleteLoc();
}
#include <iostream>
usingnamespace std;
class Cexample{
public:
virtualint example();
int xyLoc[50][25];
private:
int i, j;
};
int Cexample::example()
{
for(i = 34; i<46; i++){
for(j=3; j<23; j++){
if(i < 35 || i > 44){
xyLoc[i][j] = 1;
}
elseif(((i>34 && i<45))&&(j<4 || j>21))
xyLoc[i][j] = 1;
}//end for
}//end for
xyLoc[37][15] = 1;
xyLoc[38][13] = 1;
xyLoc[39][14] = 0;
return 0;
}
void deleteLoc()
{
Cexample ex;
ex.xyLoc[37][15] = 0; //heres the problem, xyLoc[37][15] doesn't change its
//value, it is still 1,
//so the function called by main cannot change the
//value of the function of a class? What is the proper
//way of changing the value of the function of the
//class? using the function called by main.
cout << ex.xyLoc[37][15] << endl;
}
int main(){
deleteLoc();
return 0;
}