Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerSaver & Wifi class cannot be assigned #23

Open
stoffera opened this issue Jul 18, 2017 · 3 comments
Open

PowerSaver & Wifi class cannot be assigned #23

stoffera opened this issue Jul 18, 2017 · 3 comments
Assignees
Labels

Comments

@stoffera
Copy link
Contributor

The assignment operator from #15 does not work

Problem

The assignment operator for both classes does not define its parameter as const, which it needs to be. The operator right changes the object which is assigned, therefore it cannot be const.

Solution

The operator overload must be const. This means the parameter (the object that gets assigned) cannot be changed. This means there need to exists two copies of the object, which can be problem for the Wifi class, since it owns an instance of ModuleSPICommunication

@stoffera stoffera added the bug label Jul 18, 2017
@stoffera stoffera self-assigned this Jul 18, 2017
@jpsecher
Copy link
Contributor

Maybe mutable will come in handy?

@stoffera
Copy link
Contributor Author

@jpsecher So inside the Wifi class we mark its member ModuleSPICommunication as mutable- to allow it to change - even if the owning object is const?

@jpsecher
Copy link
Contributor

Yes, although I don't know if that is a good idea in this particular case, haven't looked at the code...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants