Reputation: 5
class calcBMI {
public:
string line;
string line2;
fstream search;
short loop = 0;
string weight[6];
string height[6];
int index[6] = { 1, 2, 3, 4, 5 };
int i;
void getWeight() {
search.open("name.txt"); //Opens the text file in which the user details are stored
if (search.is_open())
{
while (getline(search, line)) { //While the program searches for the lines in the text file
if (line.find("Current Weight(KG): ") != string::npos) { //If the string "Name" isnt the last word on the line
weight[loop] = line; //Assings the strings read from the text file to the array called weight
cout << index[loop] << ". " << weight[loop] << endl; //Outputs the index array which loops through the numbers in the array and outputs the weight variable which loops through the strings in the array
loop++; //Iterates the loop
}
}
}
}
void getHeight() {
if (search.is_open())
{
while (getline(search, line2)) { //While the program searches for the lines in the text file
if (line2.find("Height") != string::npos) { //If the string "Name" isnt the last word on the line
height[loop] = line2; //Assings the strings read from the text file to the array called weight
cout << index[loop] << ". " << height[loop] << endl; //Outputs the index array which loops through the numbers in the array and outputs the weight variable which loops through the strings in the array
loop++; //Iterates the loop
}
}
}
}
void calculateBMI() {
calcBMI a;
a.getWeight;
a.getHeight;
}
};
Im using a class with functions to calculate a user's BMI by getting data from a txt file. However, i keep getting the following error:'calcBMI::getHeight': non-standard syntax; use '&' to create a pointer to member
Upvotes: 0
Views: 305
Reputation: 1775
You need ()
at the end of getWheight;
and getHeight;
void calculateBMI()
{
calcBMI a;
a.getWeight();
a.getHeight();
}
Upvotes: 1