Can someone please explain these functions when creating a class please. Searching hasn't helped much. I need to know how they are used and examples or links to examples would be helpful. Any help is appreciated.
Dexxta27
14
Junior Poster in Training
Recommended Answers
Jump to PostCan someone please explain these functions when creating a class please. Searching hasn't helped much. I need to know how they are used and examples or links to examples would be helpful. Any help is appreciated.
"Get & Set" are kind of informal terms used to describe functions that allow …
Jump to PostThese functions stem from the guideline that data members should be kept private to avoid losing control over your data. For example:
#include <iostream> #include <string> class CellPhone { public: std::string number; CellPhone(const std::string& number): number(number) {} }; int main() { CellPhone myPhone("555-123-4567"); std::cout<< myPhone.number <<'\n'; myPhone.number …
All 5 Replies
ravenous
266
Posting Pro in Training
Narue
5,707
Bad Cop
Team Colleague
Dexxta27
commented:
Great use of examples
+0
thelamb
commented:
Excellent post
+3
Dexxta27
14
Junior Poster in Training
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
Dexxta27
commented:
very helpful
+0
Dexxta27
14
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.