C++
C++
Int main(){
String str;
cout<<”Enter a string:”;
getline(cin,str);
string result= str;
for (int i=0;i<str.length();i++){
if (str[i]==’){
str.erase(I,1);
i--;
}
}
}
Cout<<”Result:”<<str<<endI;
Return 0:
}
6. State the rules for naming the identifiers in C++ programming language
❖ Only alphabetic chars, digits and underscores are permitted
❖ The name can’t start with a digit
❖ Upper case and lower case letters are distinct
❖ A declared keyword can’t be used as a variable name
7. List any two applications of OOP
❖ Graphical user interfaces (GUIs): OOP is used to create graphical user interface,
where objects represent different components of the interface such as buttons,
menus and windows
❖ Game development: OOP is used to create games, where objects represent different
game elements such as characters, enemies and obstacles
8. Explain what are access modifiers and list the three types of access modifiers
✓ Access modifiers are used to control accessibility of class members
Types of access modifiers in C++
• Public: members declared as public can be accessed from anywhere, including
outside the class
• Private: members declared private can only be accessed from within the class
• Protected: members declared protected can be accessed from within the class and
its derived classes
9. What do you understand about polymorphism in C++?
• Polymorphism is a feature of OOP that allows object of different classes to be
treated as if they were objects of the same class. Polymorphism enables the use of a
single function or operator to handle different types of data, making the code more
flexible and reusable
10. Discuss how structure is different from class
❖ Structure: It is a value type data type that can contain a combination of data types
such as integers, floats and characters.it is typically used to represent a collection of
related data items
❖ Class: It is a user defined data type that can contain data members and member
functions