Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) operator!

 

operator! (pronounced 'logical not operator') is an operator to do a logical not on a boolean. In other words: !true is false, and !false is true.

 

The example code below asserts that a std::string is not empty, before returning the first character of it.

 

#include <cassert>
#include <string>

char GetFirstChar(const std::string& s)
{
  assert(!s.empty());
  return s[0];
}

int main()
{
  assert(GetFirstChar("Bilderbikkel")=='B');
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict