E
E
empty_project2019-03-23 22:54:35
C++ / C#
empty_project, 2019-03-23 22:54:35

How to access private fields without friend functions?

Let's say we need to write a List class. We have a Node class. Correctly, all fields of a class should be private. But how then can you get access to the private fields of the Node in the List without friend-functions?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
devalone, 2019-03-23
@devalone

friend class :)

S
Sergey Sakhno, 2019-03-23
@Punk_Joker

via pointer)

J
jcmvbkbc, 2019-03-23
@jcmvbkbc

It's not clear what the relationship between List and Node is.
In a correct way, private fields should be private, and those that need access from the outside should be public or protected.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question