C++ Viva Points
C++ Viva Points
• Encapsulation: The bundling of data and methods that operate on that data into a
single unit, known as a class.
• Inheritance: The mechanism that allows a class to inherit properties and behaviors
from another class, promoting code reuse.
4. Review of C:
• Presumably, the text includes a review of the C programming language, which serves
as a foundation for understanding C++.
• Highlights distinctions between C and C++, emphasizing features like cin and cout for
input and output, as well as the new and delete operators for dynamic memory
management.
6. Object:
7. Class:
8. Public:
• Members declared as public are accessible from anywhere in the program. They can
be accessed by objects of the class, as well as from outside the class.
9. Private:
• Members declared as private are not accessible from outside the class. They can
only be accessed within the class. Private members are encapsulated within the
class and are not visible to the external world.
10. Protected:
• A feature in C++ that allows multiple functions with the same name but different
parameter lists, enabling flexibility and code readability.
• Another feature in C++ that allows the definition of custom behaviors for operators
when applied to user-defined types or objects.
• The process in which the method or function call is resolved at runtime, enabling
polymorphic behavior through virtual functions in C++.
• C++ introduces dynamic memory allocation and deallocation using new and delete
operators, providing more control over memory resources compared to C.
• Encapsulation: The bundling of data (attributes) and methods that operate on the
data into a single unit, known as a class.
• Using classes to create abstract data types, allowing the definition of data structures
and operations without specifying implementation details.
• Objects are instances of classes. Classes define the blueprint or template, while
objects are actual instances created based on that blueprint.
• Methods: Functions that define the behavior or actions that the object can perform.
20. C++ Class Declaration:
• Syntax and structure for declaring classes in C++, specifying attributes and methods.
• The process of creating instances of a class, resulting in objects with their own set of
attributes and behaviors.
• Providing default values for function parameters, allowing flexibility when calling
functions.
• Different types of objects based on classes, each with its own state and behavior.
• C++ typically relies on manual memory management, and the term "garbage
collection" here may refer to the process of releasing unused memory, especially
when dynamic memory allocation is involved.
• Allocating memory for objects during runtime using operators like new and
managing memory deallocation using delete.
29. Inheritance:
• The mechanism that allows a class to inherit properties and behaviors from another
class. It promotes code reuse and supports the creation of a hierarchy of classes.
30. Polymorphism:
• The ability of a class to take on multiple forms. This can be achieved through
function overloading and overriding, enabling flexibility and adaptability in the code.
• Keywords like public, private, and protected that control the visibility and
accessibility of class members.
• Functions that are not members of a class but have access to its private and
protected members. They are declared using the friend keyword.
• The ability to redefine how operators work for user-defined data types, providing a
natural and intuitive interface for objects.
• Members (both variables and functions) that belong to the class rather than
instances of the class. They are shared among all objects of the class.
• Special constructors used for creating a new object as a copy of an existing object.
• Derivation – Public, Private & Protected: Different access specifiers for inheritance,
controlling the visibility of inherited members.
38. Aggregation:
• The association between objects where one object contains another object, but they
can exist independently.
• Composition: Objects of one class are composed of objects of another class. The
composed objects do not exist independently.
40. Polymorphism:
• The ability of a class to take on multiple forms, allowing flexibility and adaptability in
the code.
• Redefining how operators work for user-defined data types, providing a natural and
intuitive interface for objects.
• Classes that cannot be instantiated and may contain pure virtual functions. They
serve as a blueprint for derived classes.
48. Interfaces:
• Abstract classes with only pure virtual functions, defining a contract that derived
classes must adhere to.
• Functions marked as virtual in the base class to enable function overriding in derived
classes, facilitating polymorphic behavior.
52. Function Overriding:
• Replacing a virtual function in a base class with a function in a derived class with the
same signature.
• Defining multiple functions with the same name but different parameter lists,
providing versatility and improving code readability.
• A challenge in multiple inheritance where a class derives from two classes that have
a common ancestor, potentially leading to ambiguity.
• Achieved through function overriding and virtual functions, allowing flexibility and
adaptability at runtime.
• Generic Function: A function that can operate on different data types without
specifying the type explicitly.
• Defining multiple functions in the same scope with the same name but different
parameter lists, enabling flexibility and enhancing code readability.
• A feature in C++ that allows a class to inherit from more than one class, enabling the
incorporation of features from multiple sources.
• Persistent Objects: Objects whose state is stored and retrieved, allowing data to
persist across program executions.
• Streams and Files: Mechanisms in C++ for input and output operations, including
reading from and writing to files.
• Classes that can work with different data types using templates, providing flexibility
and code reuse.
• Templates in C++ that allow the creation of generic functions. Function templates
use placeholder types to work with various data types.
• Similar to function templates, class templates allow the creation of generic classes
that can work with different data types.
• A feature in C++ that allows the conversion of a pointer or reference to a base class
into a pointer or reference to a derived class at runtime.
• Operations such as opening, closing, reading, and writing files in C++. Understanding
file modes, error handling, and file positioning.
• Exception handling mechanism in C++ where code within the "try" block is
monitored for exceptions, and the "catch" block handles the exceptions that occur.