0%
  
    
  
  
  
  
    
    
      
      
    
    
      
      
    
    
    
      
      
    
      
    
    
    
    
        
基本概念
c与cpp 的区别
| 语言 | 
c | 
cpp | 
 | 
Object Base(基于对象) | 
Object Oriented(面向对象) | 
 | 
面对**单一的class(类)**设计 | 
面对多重classes的设计,着重于class之间的关系 | 
| 头文件的书写区别 注(头文件的后缀名在不同平台可能不同)引用c的头文件要在前面加c | 
<stdio> | 
<cstdio> <iostream> | 
防卫式生命
为了解决引用顺序的问题
1 2 3 4
   | #ifndef __FILENAME__ #define __FILENAME__ ... #endif
   | 
 
头文件布局
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
   | #ifndef __FILENAME__ #define __FILENAME__
  class B
 
  class complex{
  }
 
  complex::method(){
  } #endif
   | 
 
class声明(模板类)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
   | #ifndef __COMPLEX__ #define __COMPLEX__ template <typename T> class complex{ public: 	complex(T r=0,T i=0):re(r),im(i){} 	complex& operator +=(const complex&); 	T real() const {return re;}  	T imag() const {return im;}
  private: 	T re,im; 	friend complex& __doapl(complex*,const complex&); } #endif
   | 
 
1
   | complex<double> complexDouble(1.0,2.0);
   |