In: Computer Science
A header file contains a class template, and in that class there is a C++ string object.
Group of answer choices(Pick one)
1)There should be a #include for the string library AND a using namespace std; in the header file.
2)There should be a #include for the string library.
3)There should be a #include for the string library AND a using namespace std; in the main program's CPP file, written before the H file's include.
Correct Answer:-
1
(There should be a #include for the string library AND a using namespace std; in the header file)
Explanation:-
We can also include iostream library instead of string library but we must need to use using namespace std; because string is a part of std. If we dont want to use it - We can use an alternate by only including string library using #include and declaring string like below:
std::string
You can see below that program is only running when we include string library as well as a using namespace std; in header file!
----------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERIES!!!
HIT A THUMBS UP IF YOU DO LIKE IT!!!