Question about level of skill

Hello, im new to most of this and i had a moment were i was wondering if im behind or there are some elements of the course.

Basically the moment was during the challenge “Use the std namespace” I looked at the challenge for a bit and the only thing that i could think of was deleting “std ::” The problem is i didnt know to type “using namespace” and im not sure how i was supposed to know how to do that.

Was it supposed to be something i knew in advance? was it something from a previous section? or are there lecture notes that i should have read in advance.

Anyway, i would appreciate hearing other peoples experiences with this subject.

Thanks,
Dharmesh

The using namespace was discussed in video 17. When you #include a library in C++ you are in essence pasting the entire library to the head of your file. Some functions of that library may be packaged together with similar functions in what is called a namespace.

A good metaphor for this would be to think of the library as a section in the supermarket called produce. Within the produce library are several name spaces called fruits and vegetables, and within the fruits name space is an apple.

so to call my apple function my code would look like this:

#include <_produce_>

using namespace _fruit_;

int main()
{
    _apple_::cout << "this is a metaphor";
    return 0;
}

This is probably confusing you more but what I am trying to show you here is the structure of the library and how to access its function syntactically. So it would look like this in C++:

Library - iostream | Produce
- namespace - std | Fruit
- function - cout | Apple

I hope this helps.

1 Like

Privacy & Terms