#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
?
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.
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.
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.
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>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With