View Single Post
Posts: 190 | Thanked: 129 times | Joined on Mar 2010 @ Bavaria, Germany
#6
Code:
 error: passing ‘const Service’ as ‘this’ argument of ‘QString Service::getName()’ discards qualifiers
Getters should always be const! So the error message is right.

that's would be good, but i've to pass these pointers to other class in order to edit them, so i think i can't use non-pointer...am i right?!
You should read something about pointer dereferencing. Also non-pointer variables can be made to pointer variables and vice versa.
Code:
Service service;
Service* servicePointer = &service;
Service& serviceReference = service;
Service& serviceReferenceFromPointer = *service;
nice this way, but...should i store manually the list's size before store elements?
Otherwise you won't know how much elements you have to read the next time If you create a QList<Service*> and call the shift operator for the QDataStream, your datastream will fill something strange (or it crashes). Since the QList operator for the QDataStream does not know that it should create a Service instance with "new".

what's the matter with this?! i'm still so confused about reference and pointer
References and pointers are the same in some ways. I can't explain this in english, maybe you should read some c++ tutorials for that.
 

The Following User Says Thank You to gri For This Useful Post: