Recall & Review
beginner
What is a namespace in C++?
A namespace is a way to group names (like functions, variables) to avoid conflicts between them. It helps organize code and prevents name clashes.
Click to reveal answer
beginner
Why do we use the
std namespace in C++?The
std namespace contains all the standard C++ library features like cout, vector, and string. Using std:: tells the compiler to look inside this namespace.Click to reveal answer
beginner
How do you use a function from the
std namespace without writing std:: every time?You can write
using namespace std; at the top of your code. This lets you use names like cout directly without std:: prefix.Click to reveal answer
intermediate
What problem can happen if you use
using namespace std; in large projects?It can cause name conflicts if different libraries have functions or variables with the same name. This makes the code confusing and can cause errors.
Click to reveal answer
beginner
How do you define your own namespace in C++?
You write
namespace myName { /* code here */ }. Inside the braces, you put your functions or variables. This keeps them separate from other code.Click to reveal answer
What does
std::cout mean in C++?✗ Incorrect
std::cout means the cout object inside the std namespace, used for output.
Which line allows you to write
cout instead of std::cout?✗ Incorrect
using namespace std; lets you use all names from std without prefix.
What is the main purpose of namespaces?
✗ Incorrect
Namespaces help organize code and prevent name clashes.
How do you define a namespace named
tools?✗ Incorrect
Use namespace tools { } to define a namespace.
What risk comes with using
using namespace std; in big projects?✗ Incorrect
Using using namespace std; can cause name conflicts in large projects.
Explain what a namespace is and why the
std namespace is important in C++.Think about how namespaces help keep code organized and how std contains standard library features.
You got /4 concepts.
Describe the pros and cons of using
using namespace std; in your C++ programs.Consider when it is helpful and when it might cause problems.
You got /4 concepts.