我想在类中创建一个数组hash
并在其方法中使用它。我尝试在其中声明它,public
但仍有其他方法无法访问它。这是我的班级声明:
class hash
{
public:
string hash_table[size]; //size is global variable;
void initialize(int,string*,int); //I pass `hash_table` pointer and two other `int` type //arguments.
int hash_function(string, int);
void quad_prob(int, int, string* , string); //`hash_table` array is used in this method also.
void print(string*); //to print `hash_table` array
};
我必须只使用数组。
另外,请解释一下当我使用hash h;
in时int main()
,会发生什么?这是完整的代码(不使用类结构):http ://codepad.org/DQggdoI6