Omer Obaid
Omer Obaid

Reputation: 416

Error:Invalid Argument

I'm having issue in this line of code

GsmMeasurements * gsm_measurements = new GsmMeasurements(*(request->get_mr()));

and the error is:

assing ‘const Request’ as ‘this’ argument of ‘virtual gfp::MeasurementReport* Request::get_mr()’ discards qualifiers [-fpermissive]

prototype of GsmMeasurements is

GsmMeasurements(const gfp::MeasurementReport& mr);

prototype of get_mr is

gfp::MeasurementReport* RequestA::get_mr ( )

RequestA inheriting Request

I'm unable to understand why this error is coming.

Upvotes: 1

Views: 144

Answers (1)

Bathsheba
Bathsheba

Reputation: 234665

gfp::MeasurementReport* RequestA::get_mr ( ) needs to be changed to

gfp::MeasurementReport* RequestA::get_mr ( ) const

This is because request is a pointer to a constant object, so any function needs to be marked const.

Your question text is so comprehensive that, I believe, this can be the only possibility.

Upvotes: 2

Related Questions