What is the main purpose of a namespace in C++?
- To store variables
- To group identifiers and avoid name conflicts
- To create new functions
- To allocate memory
Explanation
- A namespace in C++ is used to organize code into logical groups.
- It helps avoid name conflicts when different parts of code use the same names.
- For example, two libraries can have functions with the same name but in different namespaces.
- The std namespace (e.g., std::cout) is a common example.
- Namespaces improve code clarity and maintainability.
Related MCQs
- 5
- 8
- SyntaxError
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
حروف، اعداد اور خاص علامات پر مشتمل پاس ورڈ زیادہ مضبوط کیوں سمجھا جاتا ہے؟
- It reduces password length
- It increases possible combinations
- It is easier to remember
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
مندرجہ ذیل میں سے ڈیٹا پروسیسنگ کی درست ترتیب کون سی ہے؟
- Input → Processing → Output → Storage
- Processing → Input → Storage → Output
- Storage → Input → Processing → Output
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
ڈبل انڈر لائن کے لیے شارٹ کٹ کی کیا ہے؟
- Ctrl + Shift + D
- Ctrl + Ctrl + Shift + B
- Ctrl + Ctrl + Shift + U
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
سنٹرل پروسیسنگ یونٹ کس کام کا ذمہ دار ہے؟
- Processing instructions and calculations
- Displaying images and associated text
- Typing input for processing
- None of these