Classes & Objects
Public & Private
Data Members
Constructors
Data Functions
100

What is a class?


A user-defined type that contains both data and functions.

100

Why do we use public and private in C++?

usually to differentiate between sensitive information and information

100

How do access specifiers affect data members?

Public and private control visibility and access

100

What is a constructor?

The function that is automatically called when an object is created

100

Are Data Functions (Public or Private)?

Data functions are public

200

How many objects can be used in a class?

As many as necessary (No limit) 

200

What is data hiding in c++?

Process of hiding elements of a program's code from object members

200

Are data members (Public or Private)?

Data members are private by default 

200

Where are constructors declared?

 They are declared in the class

200

Where should member functions be implemented?

Outside the class definition, using the : : operator

300

What is a member variable?

A variable that is defined within a class and is associated with an object

300

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

300

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.

300

What is the main purpose of constructors in c++?

To construct an object and assign values to the object's members

300

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.

400

What is encapsulation?

When a class has this, it prevents direct access to its internal data and ensures that it can

400

 Are c++ members default public or private?

They are private by default

400

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.

400

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.

400

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.

500

Why do you need :: (double-colons) when defining a member function?

This tells the compiler that the function is a member of a class

500

In a class function what can change the answer of the class (The public or the private sector)?

The private sector

500

Can a const data member be initialized inside the constructor?

Yes, but only through the constructor initializer list

500

Can a c++ constructor return a value?

A return statement in the body of a constructor cannot have a return value

500

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).

M
e
n
u