Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
// m_values is of type std::vector<std::pair<std::string,INIValue> >
std::find_if(this->m_values.begin(),this->m_values.end, [name](std::pair<std::string,INIValue> v)->bool { return v.first == name;});
Below is the error:
error: no matching function for call to ‘find_if(std::vector<std::pair<std::basic_string<char>, INIValue> >::iterator, <unresolved overloaded function type>, INISection::value(const string&)::__lambda0)’
what am I missing?
You forgot braces for the second parameter.
this->m_values.end()
Also you might want to adjust your lambda a little bit. You search for a value, no need to copy each one of the vector.
[&name](const std::pair<std::string, INIValue> &v)->bool { return v.first == name;}
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm trying to solve a balanced parentheses problem, here in my code I'm trying to get 1 from a function is_empty() if top of my stack is empty but then here i am stuck with this ugly error.
int is_Empty()
{
int x=0;
if (top==NULL)
{
x=1;
}
return x;
}
here is how i recive it
if (s1.is_Empty==1)
{
cout<<"matched"<<endl;
}
my error log
bal.cpp:112:20: error: invalid use of member 'int stack::is_Empty()' (did you forget the '&' ?)
if (s1.is_Empty==1)
~~~^~~~~~~~
if (s1.is_Empty==1)
That is not how to call a function.
Here:
if (s1.is_Empty()==1)
You may wish to review your C++ book.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I have a vector of pairs which consist of a string and an integer, for example: {("ABC", 15), ("DEFG", 29)}. I want to split the string into separate characters in a vector so, {'A', 'B', 'C'}. My code is:
for (std::pair<std::string, int> i: code)
{
std::vector <char> letters;
for (char b: i.first())
'Code' is the original vector. This code gives me the error:
error: type 'std::__1::basic_string<char>' does not provide a call operator
for (char b: i.first())
^~~~~~~
I do not understand this, is there anyway to fix this?
std::pair's first is a member variable, not a method. Remove the brackets after first.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
So I'm creating this function as part of a larger program for my C++ course, and I am getting this error: no match for 'operator<<' followed by a bunch of gibberish whenever the compiler goes through this function
void print24hour(Time& start)
{
cout<<"The lecture starts at: ";
cout<<setfill('0')<<setw(2)<< start.getHours <<":"<<setfill('0')<<setw(2)<<start.getMinutes<<":"<<setfill('0')<<setw(2)<<start.getSeconds;
}
void print24hour(Time& end)
{
cout<<" and ends at: ";
cout<<setfill('0')<<setw(2)<<end.getHours<<":"<<setfill('0')<<setw(2)<<end.getMinutes<<":"<<setfill('0')<<setw(2)<<end.getSeconds<<endl;
}
Any solutions to my problem would be greatly appreciated
To get a function's return value you need to call it. Do this by appending parantheses to the member functions like end.getMinutes().
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm attempting to create a vector of vectors of complex numbers, however it will not work, previous research indicates that the following should work
vector <vector <complex<double> > test(1,vector<complex<double> >(3));
it does not
I can't figure out why and I am going crazy trying to figure out why, I get the following error
error: template argument 1 is invalid
Can anyone figure out why?
You are missing one >:
vector<vector<complex<double> > > test(1, vector<complex<double> >(3));
// ^
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I have a function
int Customer::myFunction(char * cPhoneNumber)
{
//Something here
}
And i am trying to call this function with a parameter like:
char cPhoneNumber[MAX_STRING_LENGTH]; //MAX_STRING_LENGTH = 256
memset(cPhoneNumber, 0, sizeof(cPhoneNumber));
//Some value assigned
myFunction(cPhoneNumber);
But i get this error here:
cannot convert parameter 1 from 'char [256]' to 'char'
Why am i unable to pass this, please help.
The error is telling you that the declaration of Customer::myFunction is actually:
Customer::myFunction(char cPhoneNumber); // note char, not char*
You showed us the definition, but not the declaration. Either that, or you didn't post your definition correctly.