What is "std" and "::" .Like for example, std::cout. Now i know what is cout for but what is std and what are these "::" for?

std is a system-level namespace. If you want to set the namespace for a section of code, you can do so with the "using namespace <name>" directive. IE:

using namespace std;

int foo(int value)
{
    cout << "value==" << dec << value << endl;
}

Without the "using" directive, you'd have to do this:

int foo(int value)
{
    std::cout << "value==" << std::dec << value << std::endl;
}

That said, a lot of standard C++ header files will do the "using namespace std;" for you, which is why you often don't see the "std::" part of these elements.

Now i know what is cout for but what is std and what are these "::" for?

The :: operator is called the scope resolution operator. It's primarily there for accessing names declared in a namespace or class, and std is the C++ library's namespace. std::cout says to look for cout in the std namespace and fail if it's not there.

Thanks guys for the answer

So, std is a namespace?
And how we know the syntax inside std?

So, std is a namespace?

Yuppers.

And how we know the syntax inside std?

I don't understand the question.

I don't understand the question.

Forgive me, i am a novice in C++ language. :)
I mean "coutt" is inside std isn't?
so, are there another function(beside coutt) inside std?

so, are there another function(beside coutt) inside std?

Everything in the standard C++ library is wrapped inside the std namespace.

Everything in the standard C++ library is wrapped inside the std namespace.

So, well.. thankyou very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.