Can anyone explan the main idea of using set and get function , because im confusing between them .:-/
لولوة 0 Newbie Poster
Recommended Answers
Jump to Postclass Example { int x; };
Example::x is a private data member. This means that only friends and the Example class itself can access it. This is good practice, data members should be private. But let's say you still want to give users of the class restricted …
Jump to PostCome on kids... You read in some book that that you MUST use getters and setters and suddenly you all jump on the band wagon.
Hell I'd even argue against the need for object orientated design. The exact same model can be achieved via functional programming.
Lets not go off …
Jump to PostJust make everything public then you don't need to!
Please reread Narue's response -- carefully -- and you will see why this is a bad suggestion.
Jump to PostSome would argue that get and set methods themselves are a symptom of bad design, but even in those situations, they are still superior than providing direct access to a private member variable because they at least do you the service of preventing someone from obtaining a pointer-to your class' …
Jump to PostOr let's say you don't create an object that is itself const.
int main() { T t(42); display(t); return 0; }
But we have this
display()
function. It has no business changing anything in the object, it just displays stuff. Since it doesn't change the object, …
All 17 Replies
Fbody 682 Posting Maven Featured Poster
لولوة 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague

iamthwee
Narue commented: At least include something in the post to show that you're joking. -4
mrnutty 761 Senior Poster
Excizted 67 Posting Whiz

iamthwee
Excizted 67 Posting Whiz
mrnutty 761 Senior Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Bench 212 Posting Pro
Sulley's Boo commented: riiiiiiiiiiiiight +6
Zjarek 2 Junior Poster in Training
Narue 5,707 Bad Cop Team Colleague
Excizted 67 Posting Whiz
mrnutty 761 Senior Poster
Excizted 67 Posting Whiz
Dave Sinkula 2,398 long time no c Team Colleague
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.