Hi folks,

I get this error message on this line when I try to count the amount of characters in a string. I wanted to count the characters so I can manipulate how the output is shown. It tells me no argument is made whereas I feel that the particular line (In Bold) where the error occurs is precisely the argument I might need to count it. What is wrong with this if statement: Pls Help!
Thanks

class Party
{
private:
string str1;
string str2;
public:
Party(string n = "Bruce Willis", string a = "The BamBoo Cult")
{
str1 = n;
str2 = a;
}
void GetInfo();
void DisplayInfo();
};
void Party::GetInfo()
{ 
cout <<"Enter student name\n";
cin >> str1;
cout <<"\n\nPlease enter students fraternity or cult\n\n";
cin >> str2;
}
void Party:DisplayInfo()
{
if (str1.size() >= str1.size(15))
{
cout << "\n****************************************\n";
cout <<"\n " << str2 <<" \n";
cout <<" "<< str1 <<" \n";
cout <<"\n******************************************\n";
}
else
{
cout << "\n "<< str2 <<": " << str1;
}
}
int main()
{
Party PartyDay;
PartyDay.GetInfo();
PartyDay.DisplayInfo();
return 0;
}

Ok I figured it out. But I still have another problem. Apparently what I was doing wrong was I should have changed that line to

if (str1.size() > 15)

So now, I dont have any more errors but its not doing what I'd like it to do. Regarding the cin<<str1;
I would like to enter in a stringed line which may contain spaces for both str1 & str2, and I can figure out which cin command would be most useful. Ive tried using the cin.getline function and the {cin.get(); cin.ignore()} to enter str1 & str2, but it seems that when it executes it combines both str1 & 2 together when spaces are involved without pausing for str2's input.

Can someone pls help?
Thnks

Hi folks,

I get this error message on this line when I try to count the amount of characters in a string. I wanted to count the characters so I can manipulate how the output is shown. It tells me no argument is made whereas I feel that the particular line (In Bold) where the error occurs is precisely the argument I might need to count it. What is wrong with this if statement: Pls Help!
Thanks

class Party
{
private:
string str1;
string str2;
public:
Party(string n = "Bruce Willis", string a = "The BamBoo Cult")
{
str1 = n;
str2 = a;
}
void GetInfo();
void DisplayInfo();
};
void Party::GetInfo()
{ 
cout <<"Enter student name\n";
cin >> str1;
cout <<"\n\nPlease enter students fraternity or cult\n\n";
cin >> str2;
}
void Party:DisplayInfo()
{
if (str1.size() >= str1.size(15))
{
cout << "\n****************************************\n";
cout <<"\n " << str2 <<" \n";
cout <<" "<< str1 <<" \n";
cout <<"\n******************************************\n";
}
else
{
cout << "\n "<< str2 <<": " << str1;
}
}
int main()
{
Party PartyDay;
PartyDay.GetInfo();
PartyDay.DisplayInfo();
return 0;
}

Use getline to handle it:

getline(cin, variableGoesHere);

But remember, cin leaves a newline in the input buffer, so if you use cin calls before this (not necessarily in this case), you'll have to call cin.ignore to clear the input buffer.