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
یونیورسل ٹیورنگ مشینوں کا خیال کون تیار کرتا ہے جو پہلے کمپیوٹر کی بنیاد بنتی ہے؟
- Bill gates
- Alan Turing
- Babbage
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
ای میل کا مطلب کیا ہے؟
- Easy mail
- Electronic mail
- Electric mail
- Eye mail
اس سوال کو وضاحت کے ساتھ پڑھیں
ڈیٹابیس میں کالمز کو کیا کہتے ہیں؟
- Rows
- Fields
- Records
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
کمپیوٹر سائنس کا بانی کون ہے؟
- Augusta Adaming
- Allen Turing
- Charles Babbage
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
ٹورنگ ٹیسٹ کس سال متعارف کروایا گیا؟
- 1936
- 1945
- 1950
- None of these