Questions about Classes

Nevermind

Last edited on
1.a.b.c : There are no real world programming examples to showcase this because it's a gross oversimplification of what is and always will be a design consideration for each individual project. It's possible that this is a misinterpretation of what is called "Encapsulation". But to say that this concept is appropriate to use 100% of the time regardless of context is lazy, and completely wrong.

2.a : There is only one point of difference between classes and structs in C++, and that is in the default accessibility of it's members.

2.b :
...is each structure a member of an array?

Huh? It can be if you tell it to. I'm afraid that I don't know what you're asking here.

2.c :
what there a good "real-world programming example to showcase this?

Not really, most of the time if you're writing code with the intention of having other people read it you try to be as clear as possible even if adding the additional label is completely unnecessary.

3.a : The "std::vector" container is a dynamically sized container that is easily adjustable and comes with a built in set of useful functions for managing arrays.

3.b : Did you really need to ask that question?

3.c : Only every single usage of a vector in real life.

4.a : There really isn't much to get. If you don't pass any arguments into a constructor, the default constructor is what gets called.

4.b : The rule of three, five and zero are pretty good to keep in mind: http://en.cppreference.com/w/cpp/language/rule_of_three
Other then that member initializer lists are handy, but not strictly required: http://en.cppreference.com/w/cpp/language/initializer_list

4.c : Any situation where the default constructor would be called and the object contains trivially\arbitrarily constructable members that would be used without being initialized first, or members that don't themselves have implicit default constructors.
Topic archived. No new replies allowed.