随笔分类 - 基础知识
在进行算法实现前,先巩固关于C++的基础知识。
摘要:1. 基本定义 模板是2. 分类 2.1 函数模板(1)作用: 函数模板可以用来创建一个通用功能的函数,以支持多种不同形参,进一步简化重载函数的函数体设计。 (2)申明方法: template函数申明 (3)实例:#includeusing namespace std;template T Max( const T x, const T y);int main(){ int a=10; int b=11; cout T Max( const T x, const T y){ return (x>y?x:y);} 2.2 类模板 2.2.13. 注意问题1. 类模板定义的...
阅读全文
摘要:(1)break直接调出当前循环体。如果是嵌套循环,他只能调出一层循环体。Exp-1:程序:#includeusing namespace std;int main(){ for(int i=0;iusing namespace std;int main(){ for(int i=0;i<3;i++) { cout<<"the first circle"<<" "<<i<<endl; for(int j=0;j<3;j++) { if(j==1) continue; cou...
阅读全文

浙公网安备 33010602011771号