說實話我對c++語言不是很懂,更談不上對用法的了解了。我一看到c++大量的英文組合就頭疼,每次上課也只是一知半解。我就像以下中的人一樣,老師上課講,我在下面昏昏欲睡。
如:lab exercise — overloading printarray①
#include
using std::cout;
using std::endl;
template< typename t >
void printarray( const t *array, int count )
template< typename t >
int printarray(const t *array,int count, int lowsubscrip, int highsubscript )
cout<< '\n';
return coun; }
int main()
const int acount = 5;
const int bcount = 7;
const int ccount = 6;
int a[ acount ] = ;
double b[ bcount ] = ;
char c[ ccount ] = "hello";
int elements;
cout << "\nusing original printarray function\n";
printarray( a, acount );
cout << "array a contains:\n";
elements = printarray(a,acount,0,acount-1);
cout << elements << " elements were output\n";out << "array a from positions 1 to 3 is:\n";
elements = printarray(a,acount,1,3);
cout << elements << " elements were output\n";
cout << "array a output with invalid subscripts:\n";
elements = printarray(a,acount,-1,10);
cout << elements << " elements were output\n\n";
cout << "\nusing original printarray function\n";
printarray( b, bcount );
cout << "array b contains:\n";
elements = printarray(b,bcount,0,bcount - 1);
cout << elements << " elements were output\n";
cout << "array b from positions 1 to 3 is:\n";
elements = printarray(b,bcount,1,3);
cout << elements << " elements were output\n";
cout << "array b output with invalid subscripts:\n";
elements =printarray(b,bcount,-1,10);
cout << elements << " elements were output\n\n";
cout << "\nusing original printarray function\n";
printarray( c, ccount );
cout << "array c contains:\n";
elements =printarray(c,ccount,0, ccount - 2);
cout << elements << " elements were output\n";
cout << "array c from positions 1 to 3 is:\n";
elements =printarray(c,ccount,1, 3);
cout<< elements << " elements were output\n";
cout << "array c output with invalid subscripts:\n";
elements = printarray(c,ccount,-1, 10);
cout << elements << " elements were output" << endl;
return 0;
這段**看了就頭大,我只會基本的,知道到開頭是:#include
輸入cin,輸出cout等等最簡單的,一旦混在一起我就兩眼抓瞎。
C 用法的學習心得
在大一的時候,我們曾經學習了兩學期的c 語言。因此說起 c 我們都不陌生,然而第一反應是感覺自己學得並不好。剛開始的時候,大家還抱著新鮮感,畢竟是我們進入大學以來接觸的第一門和專業相關的課程。還記得我們第乙個學習到的是 hello world,當時就覺得程式設計的語言很特別,自己對此也是一知半解。後...
C 用法的學習心得
2013年九月份,剛看到 c 程式設計教程 之後,對與這本書,感覺好高大上,開啟看了看裡面的內容感覺或許不會那麼難,畢竟裡面很多都是自己熟悉的單詞 短句。當一次上這門課時,才知道並不是自己想象的那麼簡單,真的好難好難。聽別人說,學完c 之後,就可以做出一些東西,然而我卻什麼也做不了。對於我而言,學習...
C學習心得二(printf用法)
printf 的格式字元 d格式符 用來輸出十進位制整數 d 按整型資料的實際長度輸出 md 使輸出長度為m,如果資料長度小於m,則左補空格,如果大於m,則輸出實際長度 ld 輸出長整型資料 o格式符 以八進位制形式輸出整數 x格式符 以十六進製制形式輸出整數 u格式符 用來輸出unsigned型資...