1.the difference of "string str=null;" and "tring str="";"
string str=null just declare the variable str,which points to a null,and don't allocate memory.
string str="" has allocated memory and str pointed to this space,which contains a "" character.
2.the difference of null and nullptr
null is a int type variable;
nullptr is a null pointer;
3.strange things
1)when you access the undefine space in string,it will not throw exception
example:
string str="aa";
cout<<str[5];
//run this code,there will be no exceptions,but the value of str[5] may be undefined.
4.inline function
The inline declaration can raise the efficiency in program.when you call a inline function,the complier will copy the inline function body to the place where calls the function.and allocating memory for the local variables in this function,the input arguments and return value will be reflected into this memory.
advantage:
(1) Just like the macro function,the inline function will be expanded in the called place,which omits those steps of ,pushing arguments into the stack,create and recycle the stack frame,and return values,
(2) When expand code,the inline function will do security check and automatic type conversion.
(3) When you declare a funtion in a class,it will be transformed to a inline function automatically.
(4) It could be debug when inline funtion is running.
disadvantage:
(1) code bloat
Inline function brings remarkable improvement in the excuting efficiency,which is a typical case of exchange time with space.As a result of inline function copy the code to the call place,it will expand the memory comsume in a program.
(2) It is not determinded by coder
The inline keyword just a suggestion to the complier,the complier will determind whether the funtion inline or not.
Matters need attention:
(1) we can not call a inline function by pointer,because,if you want to call a inline function by a pointer,it must acquire the address of the inline function,so we must creaete a entity of this funtion, the inline will defeat.
(2) we would better not define a constructor and destructor as a inline function,because,there are amount of code behind these funtion.