分不够再加

解决方案 »

  1.   

    static
    static declaratorWhen modifying a variable, the static keyword specifies that the variable has static duration (it is allocated when the program begins and deallocated when the program ends) and initializes it to 0 unless another value is specified. When modifying a variable or function at file scope, the static keyword specifies that the variable or function has internal linkage (its name is not visible from outside the file in which it is declared). In C++, when modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all the instances of the class. When modifying a member function in a class declaration, the static keyword specifies that the function accesses only static members.For related information, see auto, extern, and register.Example// Example of the static keyword
    static int i;         // Variable accessible only from this filestatic void func();   // Function accessible only from this fileint max_so_far( int curr )
    {
       static int biggest;    // Variable whose value is retained
                              //    between each function call
       if( curr > biggest )
          biggest = curr;   return biggest;
    }// C++ onlyclass SavingsAccount
    {
    public:
       static void setInterest( float newValue )  // Member function
          { currentRate = newValue; }             //    that accesses
                                                  //    only static
                                                  //    members
    private:
       char name[30];
       float total;
       static float currentRate;    // One copy of this member is
                                    //    shared among all instances
                                    //    of SavingsAccount
    };// Static data members must be initialized at file scope, even
    //    if private.
    float SavingsAccount::currentRate = 0.00154;
      

  2.   

    virtual
    C++ Specific —>virtual member-function-declaratorvirtual [access-specifier] base-class-nameThe virtual keyword declares a virtual function or a virtual base class.The elements of a virtual declaration are as follows:member-function-declaratorDeclares a member function.access-specifierDefines the level of access to the base class. Can appear before or after the virtual keyword.base-class-nameIdentifies a previously declared class type.See Virtual Function, Pure Virtual Functions and Abstract Classes, and Virtual Base Class for more information. Also see class, private, public, and protected.END C++ Specific
      

  3.   

    u'd see more details via MSDN
      

  4.   

    只能简单的说说
    static是指静态成员,它与一般成员不同的是它必须在定义时初始化,也就是说不能在构造函数中初始化,而且对它的访问不需要建立类的实例,访问形式为CMyClass::staticnumber;
    vitual是指虚成员,它的特点体现在继承方面,它可以被继承类修改以添加新的功能,是一个可扩展性的体现。
      

  5.   

    静态成员(摘自钱能C++教程)

    类是类型而不是数据对象,每个类的对象都是该类数据成员的拷贝。然而,往往需要让类的所有对象在类的范围内共享某个数据。声明为static的类成员便能在类范围中共享,称之为静态成员。

    虚拟函数
    为了实现多态性而使用的,如果你想在派生类中重新写某个成员函数,你可以在基类中把该成员定义为Virtual。这样做的好处是“可以打破使用基类的指针指向一个派生类的对象时只能调用基类的成员函数的限制”。
    (侯捷 《深入浅出MFC》中第二章讲得很详细)