Alright, im trying to understand this,
so a class is simply creating a template for an object.
class Bow
{
int arrows;
};
and an object is simply creating a specific item using the class template.
Bow::Bow(arrows)
{
arrows = 20;
}
also another question, public specifiers are used to make data members avaible in objects and private specifiers are used to make data memebers only avaialble inside the class?
The description you gave is mostly correct but your examples don’t show what you are describing.
A class describes a set of data members and member functions which can be called on those data members:
And an object of a class is simply an instance of that class.
Note: I purposely avoided the use of the word template that you used because it’s used for something entirely different in C++ than what you meant.
To understand public/private/protected specifiers:
public: means that objects of the class can use the members directly.
protected: means that objects of the class cannot use the members directly. Derived classes that are based on that class can use the members.
private: means that objects of the class cannot use the members directly. Derived classes that are based on that class cannot use the members either.
So in the above example: