Doubt in string class

Hello, why we are using append( ) method as :

s0.append( " I love c++ " );

and not like this :

append( s0, “I love c++” );

And similarly why we use empty as :

s0.empty( );

why we don’t use it as :

empty (s0);

What actually this ’ . ’ is doing in between s0 and method ?

Dot (.) operator is known as “Class Member Access Operator” in C++ programming language, it is used to access public members of a class . Public members contain data members (variables) and member functions (class methods) of a class.

the append and empty function are defined as such so we follow the syntax to implement them

1 Like

Ok thanks :slightly_smiling_face: