
Get instant access to notes, practice questions, and more benefits with our mobile app.
From Programming in C++
Functions support modular programming. Advantages:
Hence functions make large programs manageable.
C-style string is a char array ending with '\0' and often uses <cstring> functions like strlen.
std::string is a C++ class that manages memory automatically and supports easy operations like concatenation and length using methods.
C-style strings need careful size handling; std::string is safer.
A class is a blueprint/template that defines data members (properties) and member functions (behaviour). An object is an instance of a class that has actual memory.
Example:
Student (roll, name, marks)s1, s2 (actual students)Class: Student
- roll
- name
+ show()
Objects: s1, s2
Thus, classes help model real-world entities and objects represent actual entities in memory.