954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Error C2660 Function does not take 1 argument

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;
}
Prog.Learner
Newbie Poster
2 posts since Apr 2007
Reputation Points: 10
Solved Threads: 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<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;
}
Prog.Learner
Newbie Poster
2 posts since Apr 2007
Reputation Points: 10
Solved Threads: 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.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You