Hi everybody , I wonder how I can deal with such error , especially in while loop ???
{ class/struct/union
1>c:\users\m..s\documents\visual studio 2010\projects\project - initial\project - initial\hash.cpp(100): error C2065: 'Q' : undeclared identifier
1>c:\users\m..s\documents\visual studio 2010\projects\project - initial\project - initial\hash.cpp(101): error C2065: 'index' : undeclared identifier
1>c:\users\m..s\documents\visual studio 2010\projects\project - initial\project - initial\hash.cpp(101): error C2228: left of '.name' must have class/struct/union
1>c:\users\m..s\documents\visual studio 2010\projects\project - initial\project - initial\hash.cpp(106): error C2065: 'first' : undeclared identifier
1>c:\users\m..s\documents\visual studio 2010\projects\project - initial\project - initial\hash.cpp(106): error C2065: 'index' : undeclared identifier
1>c:\users\m..s\documents\visual studio 2010\projects\project - initial\project - initial\hash.cpp(108): error C2065: 'index' : undeclared identifier
1>c:\users\m..s\documents\visual studio 2010\projects\project - initial\project - initial\hash.cpp(109): error C2065: 'index' : undeclared identifier
}
bool WZhash::insert(){
int I, char * name , double C , int Q , index , K , first ;
/*
inserting a certain commodity with it's name , Id , cost and Quantity .
*/
cout<<"please insert the Id , name , cost and the quantity if the commodity respectively \n " ;
cout<<"Id :\n";
cin>>I ;
cout<<"Name : \n";
cin>>name;
cout<<"Cost :\n";
cin>>C;
cout<<"Quantity :\n";
cin>>Q;
- This shows there is an issue with the declaration of 'Q'.
A tip is that the error is usually on the same line were the error is found (but not always).
If you click the error it usually jumps to where the error is in the program.
---------------------------------------------------------------------------------------
When you declare variables of different type, then they need to be on a separate line and each line has to end with a ;
For example
1 2 3
int x, y, z;//this declares 3 variables of type int with the names x, y & z
char a, b, c;//this declares 3 variables of type char with the names a, b & c
float myFloat;//this declares a variable of type float, with the name myFloat
If you are declaring more than one variable of the same type on the same line, then you need to use a ',' between each variable name.