#includeusing namespace std;class PhoneNumber int areacode; int localnum;public: PhoneNumber(); PhoneNumber(const int, const int); void display() const; bool valid() const; void set(int, int); PhoneNumber& operator=(const PhoneNumber& no); PhoneNumber(const PhoneNumber&);;istream& operator>>(istream& is, const PhoneNumber& no);istream& operator>>(istream& is, const PhoneNumber& no) int area, local; cout > area; cout > local; no.set(area, local); return is;at no.set(area, local); it says that "the object has kind qualifiers that room not compatible with the member function"

what should i do...?


*

You"re passing no together const, but you shot to modify it.

You are watching: The object has type qualifiers that are not compatible with the member function

istream& operator>>(istream& is, const PhoneNumber& no)//-------------------------------^{ int area, local; cout > area; cout > local; no.set(area, local); //
Your set an approach is not const (nor need to it be), yet you"re attempting to speak to it ~ above a const object.

Remove the const native the parameter to operator >>:

istream& operator>>(istream& is, PhoneNumber& no)

*

In the operator >> over there is the 2nd parameter with form const PhoneNumber& no the is the is a consistent object, yet you room trying to readjust it utilizing member duty set. Because that const objects you may call only member attributes that have qualifier const.


*

Thanks for contributing solution to ridge Overflow!

Please be certain to answer the question. Administer details and share her research!

But avoid

Asking because that help, clarification, or responding to various other answers.Making statements based on opinion; back them increase with references or personal experience.

See more: Can You Bring Cologne On A Plane ? Can You Bring Cologne On A Plane

To discover more, view our tips on writing great answers.


post Your price Discard

By click “Post her Answer”, friend agree come our regards to service, privacy policy and also cookie plan


relocate constructor dubbed twice once move-constructing a std::function from a lambda that has actually by-value catches
*

site architecture / logo © 2021 stack Exchange Inc; user contributions licensed under cc by-sa. Rev2021.11.4.40656


Stack Overflow works ideal with JavaScript allowed
*

her privacy

By clicking “Accept every cookies”, you agree stack Exchange can store cookie on your machine and disclose details in accordance through our Cookie Policy.