new progammer

i understand classes it is a struct that holds functions in the members and has a protected, public, and a private type. can anybody contibute a very very basic explanation of class friendship?



the other thing is pointers and dynamic memory. i have read books and i cannot find a basic explanation of these subjects.

thank you for your time and contribution.
friendship permits other classes/functions to access the protected and private members of a class.

pointers and dynmaic memory is a big topic and there are lots of sources out there. any c++ tutorial/book will deal with these things (And friendship).
i have read books and i cannot find a basic explanation of these subjects.

I find that difficult to believe. What were those books you read?
Besides, you'll have to ask more specific questions.
Obligatory: http://www.youtube.com/watch?v=UvoHwFvAvQE
can anybody contibute a very very basic explanation of class friendship?
If A is a friend class or function of B, then A has access to B's private members.

pointers
Think of memory as a very large hotel. While it would be possible to name each room after, say, English authors, it's much easier to number them. A pointer is an integer big enough to hold any valid room number.

dynamic memory
Following the hotel analogy, think of a program as a convention. Before the convention starts, it has to reserve a certain number of contiguous rooms in advance for the staff and some number of attendees. Once it starts, it can't reserve more rooms contiguous to the original reservation (because other people have already reserved them), and the number of rooms is usually rather small. If the convention grows too big to fit in the rooms it had previously reserved, it can still ask for new blocks of rooms from management. These new blocks can be as large as necessary (although it may not be possible to allocate a very large block if other blocks had previously been allocated), more can be requested at any time, and once rooms are unused, they can be freed for the hotel to use for other things.
This is dynamic memory.

EDIT: Touched up a few details in the analogy to clarify.
Last edited on
I like the hotel analogy!
i have read books and i cannot find a basic explanation of these subjects.

I find that difficult to believe. What were those books you read?
Besides, you'll have to ask more specific questions.
Obligatory: http://www.youtube.com/watch?v=UvoHwFvAvQE


Okay i should have used a better choice of words, i have ready a few books and the topics that i have mentioned are ones that were not simply explained (simple enough for me at least) so i turned to the community for the answers.

i like the hotel analogy a lot.
Topic archived. No new replies allowed.