Originally Posted by
Salem
Like so
Code:
int getnn(int which)
{
return nn[which];
}
void setnn(int which, int value)
{
nn[which]=value;
}
Thank you very much. But after I have try, I have got a several error. I am sorry, I am a bit dump in C++, would you mind help me by teaching me slightly more explicitly? Thank you very much!!
Code:
#include <iostream> // Include input/output stream
#include <fstream> // Include file output stream
#include <cmath> // Include math function, sin, cos
class sitelist
{
private:
int state, nn[8], xcoord, ycoord, zcoord;
public:
// Default constructor
sitelist()
{
state= 0;
nn[0]=0;
nn[1]=0;
nn[2]=0;
nn[3]=0;
nn[4]=0;
nn[5]=0;
nn[6]=0;
nn[7]=0;
xcoord = 0;
ycoord = 0;
zcoord = 0;
}
int getstate()
{
return state;
}
int getnn(int 0)
{
return nn[0];
}
int getnn(int 1)
{
return nn[1];
}
int getnn(int 2)
{
return nn[2];
}
int getnn(int 3)
{
return nn[3];
}
int getnn(int 4)
{
return nn[4];
}
int getnn(int 5)
{
return nn[5];
}
int getnn(int 6)
{
return nn[6];
}
int getnn(int 7)
{
return nn[7];
}
int getx()
{
return xcoord;
}
int gety()
{
return ycoord;
}
int getz()
{
return zcoord;
}
sitelist(int st, int nn_[8], int x, int y, int z)
{
state=st;
nn[8]=nn_[8];
xcoord = x;
ycoord = y;
zcoord = z;
}
void setstate(int value)
{
state=value;
}
void setnn(int 0, int value)
{
nn[0]=value;
}
void setnn(int 1, int value)
{
nn[1]=value;
}
void setnn(int 2, int value)
{
nn[2]=value;
}
void setnn(int 3, int value)
{
nn[3]=value;
}
void setnn(int 4, int value)
{
nn[4]=value;
}
void setnn(int 5, int value)
{
nn[5]=value;
}
void setnn(int 6, int value)
{
nn[6]=value;
}
void setnn(int 7, int value)
{
nn[7]=value;
} void setx(int value)
{
xcoord=value;
}
void sety(int value)
{
ycoord=value;
}
void setz(int value)
{
zcoord=value;
}
};
Error message
Code:
sitelist.h:34: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:38: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:38: error: ‘int sitelist::getnn(int)’ cannot be overloaded
sitelist.h:34: error: with ‘int sitelist::getnn(int)’
sitelist.h:42: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:42: error: ‘int sitelist::getnn(int)’ cannot be overloaded
sitelist.h:34: error: with ‘int sitelist::getnn(int)’
sitelist.h:46: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:46: error: ‘int sitelist::getnn(int)’ cannot be overloaded
sitelist.h:34: error: with ‘int sitelist::getnn(int)’
sitelist.h:50: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:50: error: ‘int sitelist::getnn(int)’ cannot be overloaded
sitelist.h:34: error: with ‘int sitelist::getnn(int)’
sitelist.h:54: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:54: error: ‘int sitelist::getnn(int)’ cannot be overloaded
sitelist.h:34: error: with ‘int sitelist::getnn(int)’
sitelist.h:58: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:58: error: ‘int sitelist::getnn(int)’ cannot be overloaded
sitelist.h:34: error: with ‘int sitelist::getnn(int)’
sitelist.h:62: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:62: error: ‘int sitelist::getnn(int)’ cannot be overloaded
sitelist.h:34: error: with ‘int sitelist::getnn(int)’
sitelist.h:92: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:96: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:96: error: ‘void sitelist::setnn(int)’ cannot be overloaded
sitelist.h:92: error: with ‘void sitelist::setnn(int)’
sitelist.h:100: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:100: error: ‘void sitelist::setnn(int)’ cannot be overloaded
sitelist.h:92: error: with ‘void sitelist::setnn(int)’
sitelist.h:104: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:104: error: ‘void sitelist::setnn(int)’ cannot be overloaded
sitelist.h:92: error: with ‘void sitelist::setnn(int)’
sitelist.h:108: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:108: error: ‘void sitelist::setnn(int)’ cannot be overloaded
sitelist.h:92: error: with ‘void sitelist::setnn(int)’
sitelist.h:112: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:112: error: ‘void sitelist::setnn(int)’ cannot be overloaded
sitelist.h:92: error: with ‘void sitelist::setnn(int)’
sitelist.h:116: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:116: error: ‘void sitelist::setnn(int)’ cannot be overloaded
sitelist.h:92: error: with ‘void sitelist::setnn(int)’
sitelist.h:120: error: expected ‘,’ or ‘...’ before numeric constant
sitelist.h:120: error: ‘void sitelist::setnn(int)’ cannot be overloaded
sitelist.h:92: error: with ‘void sitelist::setnn(int)’
sitelist.h: In member function ‘void sitelist::setnn(int)’:
sitelist.h:94: error: ‘value’ was not declared in this scope
sitelist.h: In member function ‘void sitelist::setnn(int)’:
sitelist.h:98: error: ‘value’ was not declared in this scope
sitelist.h: In member function ‘void sitelist::setnn(int)’:
sitelist.h:102: error: ‘value’ was not declared in this scope
sitelist.h: In member function ‘void sitelist::setnn(int)’:
sitelist.h:106: error: ‘value’ was not declared in this scope
sitelist.h: In member function ‘void sitelist::setnn(int)’:
sitelist.h:110: error: ‘value’ was not declared in this scope
sitelist.h: In member function ‘void sitelist::setnn(int)’:
sitelist.h:114: error: ‘value’ was not declared in this scope
sitelist.h: In member function ‘void sitelist::setnn(int)’:
sitelist.h:118: error: ‘value’ was not declared in this scope
sitelist.h: In member function ‘void sitelist::setnn(int)’:
sitelist.h:122: error: ‘value’ was not declared in this scope