zoukankan      html  css  js  c++  java
  • 学会从已知推出未知

    作者:朱金灿

    来源:http://blog.csdn.net/clever101

       

                本人是一个英语菜鸟。因为英语是计算机的官方语言。因此学起计算机自然有了麻烦。具体的表现是看msdn常常对自己的理解感到不自信:我的理解到底对不对呢?幸好我想到了一个好办法,就通过已知的知识来推测未知的。比如我STL中的string中的成员函数erase函数的功能:

    basic_string& erase(size_type p0 = 0, size_type n = npos);

    function removes up to n elements of the controlled sequence beginning at position p0, then returns *this.

             我不知道remove up 作何解。我 通过查金山词霸,知道remove有移动、开除、移交的意思。我猜这个函数有清空字符串的功能。但是我依然不能肯定。于是我设计了一个小实验来验证我的想法。

    #include <stdio.h>
    #include <conio.h>
    #include <string>
    using namespace std;
    
    int main(void)
    {
       string str;
       str = "Hello";
       str.erase();
    
    /*之前我已经知道str.empty()是判断字符串是否为空,空则返回true。*/
       if(str.empty())printf("str is empty!/n");
       return 0;
    } 

           果然不出我的所料。erase函数的功能就是清空字符串。

  • 相关阅读:
    原型链
    computed>watch>methods;methods>watch
    rem
    Cookie、Session、Token
    :(){:|:&};:
    js匹配多选框选中项
    sass自备了一系列的函数功能。
    字符串
    ECMAScript6 入门教程记录之-编程风格
    const命令
  • 原文地址:https://www.cnblogs.com/lanzhi/p/6471329.html
Copyright © 2011-2022 走看看