access c++ private data members without using the " Friend" type
main() can be a friend function?
virsa
0
Newbie Poster
Recommended Answers
Jump to Postmaybe use get and set functions? If you're doing it without friends, it seems like making main a friend is not allowed...
Jump to Post>access c++ private data members without using the " Friend" type
Why is this such a common question? It's insanely stupid.
Jump to PostI'm just learning C++ myself...
Wouldn't you use a public member function to access and modify private member variables?
Jump to Post> Wouldn't you use a public member function to access and modify private member variables?
Yes everyone else would.But some people seem to like asking stupid questions like this which subvert the whole idea of using an OO language for data encapsulation.
Like somehow knowing that if …
All 16 Replies
Infarction
503
Posting Virtuoso
Narue
5,707
Bad Cop
Team Colleague
FC Jamison
31
Posting Pro in Training
Team Colleague
Salem
5,138
Posting Sage
Lazaro Claiborn
1
Junior Poster
Infarction
503
Posting Virtuoso
Lazaro Claiborn
1
Junior Poster
thekashyap
193
Practically a Posting Shark
John A
commented:
Don't be rude if you don't know what you're talking about.
-1
Infarction
503
Posting Virtuoso
Salem
5,138
Posting Sage
thekashyap
193
Practically a Posting Shark
John A
1,896
Vampirical Lurker
Team Colleague
thekashyap
193
Practically a Posting Shark
Infarction
503
Posting Virtuoso
thekashyap
193
Practically a Posting Shark
Laiq Ahmed
42
Junior Poster
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.