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().
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
void creatore(int c, int first, int var)
{
cell *n=new cell;
cell *n->data=first;
and this is the error
basic list.cpp:26:12: error: expected initializer before '->' token
cell *n->data=53;
can someone help me out!
You have declared your variable at
cell *n=new cell;
at the next line you are trying to re-declare it
cell *n->data=first;
Replace it with:
n->data=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 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 3 years ago.
Improve this question
I wanted to clear string from unwanted chars, and I tried to iterate it through a loop like this.
for(auto it=numer.begin(); it!=numer.end(); ++it)
{
if(*it=='-') numer.erase(it);
}
The error is: "expected primary-expression before '=' token";
I could, of course, I could do this with [] operator. But I am wondering why it doesn't work.
I appreciate your help.
If you want to remove all instances of a character from a string, a simple way to do that would be to use the standard erase-remove(if) idiom:
numer.erase(std::remove(numer.begin(), numer.end(), '-'), numer.end());
See also:
https://en.cppreference.com/w/cpp/string/basic_string/erase
https://en.cppreference.com/w/cpp/algorithm/remove
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
Why is g++ giving an error like this?
blahblah.h:80:10: error: decomposition declaration not permitted in this context
float[NUM_OUTPUTS] output_buffer;
(Already solved, but creating this because there's no good google hits for this error text, and the error message is inscrutable.)
In C++ declarations, the array size goes after the variable name, not after the type:
float output_buffer[NUM_OUTPUTS];
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
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.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I have just started to learn C++ and i would like to get some help.
The user needs to type an ID number and the format has to be the following. The first character B and the other 4 any integer.
Im trying to check if the character format are right.
So far i have this:
if ((isalpha(id[0])=='B' ) && (isdigit(id.at(1))) && (isdigit(id.at(2))) ......
{
//do something
}
else
{
cout << "Wrong format" << endl;
}
but even if i type example B8745 it says wrong format.
You are comparing the result of isalpha, which is boolean, to character literal 'B'.