Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ - std::set not declared [closed]

Tags:

c++

debugging

#include <iostream>

 using std::set;
 using std::cout;
 using std::endl;

Error reported:

Josephus_Permutation.cpp:3:13: error: ‘std::set’ has not been declared

Shouldn't std::set be a STL of namespace std?

like image 256
CDT Avatar asked Mar 11 '13 14:03

CDT


People also ask

Should we use using namespace std in C++?

The statement using namespace std is generally considered bad practice. The alternative to this statement is to specify the namespace to which the identifier belongs using the scope operator(::) each time we declare a type.

What is std :: in C++?

It is known that “std” (abbreviation for the standard) is a namespace whose members are used in the program. So the members of the “std” namespace are cout, cin, endl, etc.

Why do we use namespace std?

A namespace is designed to overcome this difficulty and is used as additional information to differentiate similar functions, classes, variables etc. with the same name available in different libraries. Using namespace, you can define the context in which names are defined.


1 Answers

It is in the std namespace but you need to include the appropriate header:

#include <set>

The <iostream> header only contains the standard input/output library, which includes std::cout and std::endl. std::set, however, is defined in <set>.

like image 136
Joseph Mansfield Avatar answered Sep 21 '22 22:09

Joseph Mansfield