+ 1

Empty function in c++

can anybody explain me that how empty function works in c++ with suitable example ?

14th Jul 2018, 8:05 PM
JD009
JD009 - avatar
6 Réponses
+ 3
The empty method in that code belongs to string class, the method returns a boolean; true when the string is of zero length (no content), and false otherwise. For better explanation of the empty method and string class see the reference: http://en.cppreference.com/w/cpp/string/basic_string http://en.cppreference.com/w/cpp/string/basic_string/empty Hth, cmiiw
14th Jul 2018, 10:08 PM
Ipang
+ 3
You're welcome JD009 : )
14th Jul 2018, 10:16 PM
Ipang
+ 1
What do you mean by "empty function"? Functions with void type? #include <iostream> void foo(){ std::cout<<"test"; } int main() { foo(); return 0; }
14th Jul 2018, 9:18 PM
Matthias
Matthias - avatar
+ 1
thanks Ipang...
14th Jul 2018, 10:13 PM
JD009
JD009 - avatar
0
i just want to know about this given below code :--- #include <iostream> using namespace std; int main() { string s1,s2; s1=""; s2="sololearn"; cout<<s1.empty(); cout<<s2.empty(); return 0; }
14th Jul 2018, 9:46 PM
JD009
JD009 - avatar
0
i just want to know how is it works ?
14th Jul 2018, 9:47 PM
JD009
JD009 - avatar