C++ Invalid use Of Member Function (Did You Forget The '()'?)
26,094
Solution 1
These lines are your problem:
for (unsigned short i = 0; i <= Cust_FName.length; i++)
for (unsigned short i = 0; i <= Cust_LName.length; i++)
// ^^
std::string::length
is a function, so you need to invoke it with parens:
for (unsigned short i = 0; i <= Cust_FName.length(); i++)
for (unsigned short i = 0; i <= Cust_LName.length(); i++)
Solution 2
I suspect that Cust_LName
is a std::string
so you should add ()
after length
:
Cust_LName.length()
Author by
Admin
Updated on February 17, 2020Comments
-
Admin over 4 years
I'm having trouble getting my program to compile. The error is happening on line 165-177. All I added was the test for the presence of letters and I got an error, hope you can help! Full Code http://pastebin.com/embed.php?i=WHrSasYk
(Attached below is code)
do { cout << "\nCustomer Details:"; cout << "\n\tCustomer Name:"; cout << "\n\t\tFirst Name:"; getline (cin, Cust_FName, '\n'); if (Quotation::Cust_FName.length() <= 1) ValidCustDetails = false; else { // Error line 165! for (unsigned short i = 0; i <= Cust_FName.length; i++) if (!isalpha(Quotation::Cust_FName.at(i))) ValidCustDetails = false; } cin.ignore(); cout << "\t\tLast Name:"; getline (cin, Cust_LName, '\n'); if (Cust_LName.length () <= 1) ValidCustDetails = false; else { // Error line 177! for (unsigned short i = 0; i <= Cust_LName.length; i++) if (!isalpha(Cust_LName.at(i))) ValidCustDetails = false; } cin.ignore(); } while(!ValidCustDetails);