What is a class?
A user-defined type that contains both data and functions.
Why do we use public and private in C++?
usually to differentiate between sensitive information and information
How do access specifiers affect data members?
Public and private control visibility and access
What is a constructor?
The function that is automatically called when an object is created
Are Data Functions (Public or Private)?
Data functions are public
How many objects can be used in a class?
As many as necessary (No limit)
What is data hiding in c++?
Process of hiding elements of a program's code from object members
Are data members (Public or Private)?
Data members are private by default
Where are constructors declared?
They are declared in the class
Where should member functions be implemented?
Outside the class definition, using the : : operator
What is a member variable?
A variable that is defined within a class and is associated with an object
What is the difference between Public and Private?
Public - members are accessible outside the class
Private - members cannot be accessed or viewed outside of the class
What is the difference between instance data Members and static data members?
Instance data members are specific to each object of a class.
nstance data members are specific to each object of a class.
Static data members are shared across all objects of the class and exist independently of any object.
What is the main purpose of constructors in c++?
To construct an object and assign values to the object's members
How are member functions different from normal functions in C++?
Member functions are associated with a class and have access to its data members and other member functions. Normal (non-member) functions are not tied to any class.
What is encapsulation?
When a class has this, it prevents direct access to its internal data and ensures that it can
Are c++ members default public or private?
They are private by default
Can a static data member be private? How is it accessed?
Yes, a static data member can be private. It is accessed using a public static member function or through a public interface.
What is a default constructor and a parameterized constructor?
Defining a parameterized constructor does not automatically create a no-argument constructor, you must give it a value. The default constructor can be assumed, or you can give it a value.
Can a member function return an object of the same class?
Yes, member functions can return an object of the same class, either by value or by reference. This is commonly used in operator overloading and method chaining.
Why do you need :: (double-colons) when defining a member function?
This tells the compiler that the function is a member of a class
In a class function what can change the answer of the class (The public or the private sector)?
The private sector
Can a const data member be initialized inside the constructor?
Yes, but only through the constructor initializer list
Can a c++ constructor return a value?
A return statement in the body of a constructor cannot have a return value
How can member functions be made inaccessible to objects of the class but still usable internally?
You can make the member function private or protected. This hides it from external access while allowing internal use within the class or derived classes (if protected).