Junior — Middle
Millistel juhtudel ja milliste objektidega kasutatakse C++-s using direktiivi?
sobes.tech AI
Vastus AI-lt
In C++, the using directive is used to simplify access to names from namespaces or to create type aliases.
Main use cases:
- Including names from a namespace:
using namespace std; // allows using names from std without the std prefix
- Including a specific name:
using std::cout; // now you can write cout instead of std::cout
- Creating type aliases:
using IntVector = std::vector<int>; // alias for the type
The using directive makes code reading and writing easier, reducing the need to write long qualified names.