zoukankan      html  css  js  c++  java
  • all objects of the same class share the same set of class methods

    #include <iostream> 
    #include "First.h" 
      
    void Test(); 
      
    int main() 
    { 
        std::cerr<<"Error,Hello!"<<std::endl; 
      
        void (*p_Function)(void)=&Test; 
        for(size_t i=0;i<sizeof p_Function;i++) 
            printf("%d",reinterpret_cast<char *>(&p_Function)[i]); 
      
        std::cout<<"
    "; 
      
        First first1,first2; 
        void (First::*p_Function_First_1)(void)=&First::Start; 
        void (First::*p_Function_First_2)(void)=&First::Start; 
        std::cout<<"First One:"<<std::endl; 
        for(size_t i=0;i<sizeof(p_Function_First_1);i++) 
            printf("%d",reinterpret_cast<char *>(&p_Function_First_1)[i]); 
        std::cout<<"
    "; 
        std::cout<<"First Two:"<<std::endl; 
        for(size_t i=0;i<sizeof p_Function_First_2;i++) 
            printf("%d",reinterpret_cast<char *>(&p_Function_First_2)[i]); 
      
        getchar(); 
        return 0; 
    } 

    反映的是:
    Each new object you create contains storage for its own internal variables, the class members.
    But all objects of the same class share the same set of class methods, with just one copy of each
    method.

  • 相关阅读:
    Java Clone
    Java Clone
    Java Clone
    Java Clone
    js数组去重
    js数组去重
    js数组去重
    js数组去重
    bat修改hosts文件
    3个赚钱思路和案例,都是暴利赚钱项目,最后一个你肯定见到过
  • 原文地址:https://www.cnblogs.com/hongjiumu/p/3485825.html
Copyright © 2011-2022 走看看