原创 大學生C++教程第九版 習題(4.25)

#include <iostream> using namespace std; void allStar(int); void spaceStar(int); int main() { int n,i; cout << "請輸入

原创 大學生C++教程第九版 習題(3_14)

#ifndef INVOICE_H #define INVOICE_H #include <iostream> #include <string> using namespace std; class Invoice { public:

原创 大學生C++教程第九版 習題(3.12)

#ifndef ACCOUNT_H #define ACCOUNT_H #include <iostream> #include <string> using namespace std; class Account { public:

原创 C++的頭文件

<iomanip> :  頭文件中聲明瞭參數化流操縱符(例如setw和setprecision)用於向格式化I/O提供有用服務。   <fstream> : 頭文件聲明瞭文件處理服務。   <stdexcept> :頭文件中定義的標準異常

原创 函數對象筆記整理

  函數對象:           重載函數調用操作符的類,其對象常稱爲函數對象。(function object)。               這是通過重載類的operator() 來實現。           在標準庫中,函數對象被

原创 大學生C++教程第九版 習題(7.21)

#ifndef PROGRAM_H #define PROGRAM_H #include <iostream> #include <iomanip> using namespace std; #include <array> #incl

原创 大學生C++教程第九版 習題(15_23)

#include <iostream> #include <array> using namespace std; #include <vector> bool decide1(vector<int> &integers2);

原创 大學生C++教程第九版 習題(10.8)

#include <iostream> #include <string> #include <iomanip> using namespace std; int main() { int i=1; cout << "N" <

原创 大學生C++教程第九版 習題(10.10)

//RationalNumber.h #ifndef RATIONALNUMBER #define RATIONALNUMBER #include <iostream> #include <string> #include <cmat

原创 P29_間接賦值是指針存在的最大意義

//它允許不同的函數操作同一塊內存空間 //函數調用時,形參傳給實參,用實參取地址,傳給形參,在被調函數裏面用*p來改變實參, 把運算結果傳出來 //c語言特有的現象,是c語言的精華 //主函數和被調函數之間通過內存交換運算結果 #de

原创 P33_字符串的基本操作

#include <iostream> #include <string> using namespace std; //字符串 //1 C語言的字符串 以零結尾的字符串 //2 在C語言中沒有字符串類型 通過字符數組 來模擬字

原创 P15 堆棧案例

//實例 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> using namespace std; //1 char* getMem(int

原创 P7 數組做函數參數退化問題

#include <iostream> using namespace std; #include <string> //void printfArray(int a[],int num) void printfArray(int *

原创 P14 內存四區的基本原理

  #include <iostream> #include <string> using namespace std; char* getStr1() { char *p1 = "abcdefg2"; return p1; }