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 5 years ago.
Improve this question
In my TimeCode.h I have following :
inline TimeCode::operator int() const;
Which should be able to execute whenever I cast TimeCode object to int.
But when I do something like :
(int) firstTimeCode > (int) scndTimeCode
The compiler throws the following error at me :
cast from 'TimeCode*' to 'int' loses precision [-fpermissive]
Does anyone know what is the problem and how it can be fixed ? Thank you very much in advance !
Look at the error message - it's telling you that you're converting TimeCode* to int - that is, at least one of your operands is a pointer to a TimeCode, not an actual TimeCode. So you need to dereference that pointer first to invoke your operator correctly.
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 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 5 years ago.
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.
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.
Improve this question
function:
name: make_shape
return: Shape*
parameters: const string &shape_name; const vector &data
The class is ShapeFactory. This is what I have for this function definition:
ShapeFactory::Shape* make_shape(const string &shape_name, const vector<double>&data)
I get an error that says:
"ShapeFactory.cpp:17:15: error: ‘Shape’ in ‘class ShapeFactory’ does not name a type"
I know Shape* isn't a return type, but I don't know how to declare the pointer. Any suggestions?
You've written ShapeFactory::Shape* make_shape, which the compiler thinks is the implementation of a function in ShapeFactory called Shape*. You need to have the return type before this, and the bit after the :: is the function name. So, the correct code is:
Shape* ShapeFactory::make_shape(const string
&shape_name, const vector<double>&data)
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 6 years ago.
Improve this question
i have a simple function, in which i need to divide two integers. But the casting does not work.
I can't understand what is wrong in my code:
double new=0.0;
if(N>0) new = double(Ns)/double(N);
The error-message at the place double new; is (error:expected unqualified-id) and at the place new=double(Ns)/double(N)
and at
new is a reserved keyword in C++. Pick another name for your variable:
double double_new=0.0;
if(N>0) double_new = double(Ns)/double(N);
new is a reserved keyword in C++. You cannot have objects named new.
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 dont have much experience in cpp, let alone systemc.
Why doenst this work?
sc_in<sc_uint<8>> a,b;
adder.cpp:5: error: ‘a’ was not declared in this scope
adder.cpp:5: error: ‘b’ was not declared in this scope
adder.cpp:5: error: wrong number of template arguments (2, should be 1)
This does work:
sc_in<int> a,b;
In C++03, you can't have the two > characters next to each other because the compiler thinks you're trying to perform a right shift.
It then gets really confused, thinking you mean this:
sc_in<sc_uint<(8 >> a), b;
// ^ ^ ^
// ? | ? Compiler: "what are `a` and `b`?!"
// ! Compiler: "why two arguments?!"
If you had managed to get that far, it would later complain about the two missing > characters before ;, ironically taking you back to where you started.
You have to write sc_in<sc_uint<8> > instead.
That's fixed as of C++11.
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.