原创 例題6.3

 #include<iostream> using namespace std; int main() { char key[5]={'b','c

原创 從1-49選6個不同的數,輸出5組(二)有錯?

#include<iostream> #include<vector> #include<ctime> using namespace std; int main() { srand( (unsigned)time(NULL) ); ve

原创 STL中的常用的vector,map,set,sort, list用法筆記(轉)

C++的標準模板庫(Standard Template Library,簡稱STL)是一個容器和算法的類庫。容器往往包含同一類型的數據。STL中比較常用的容器是vector,set和map,比較常用的算法有Sort等。 . 一. vec

原创 例題6-20,實參爲指針數組

#include<iostream> using namespace std; class point32 { private: int x; int y; public: point32(int ix,int iy) { x

原创 擴展練習4(學生類設計).設計一個友元函數,按照成績從高到低的順序輸出姓名、學號和成績信息

#include<iostream> using namespace std; class CStudent{ private: int id_,math_,forlan_,computer_; char *name_; public

原创 c++繼承時的構造函數

1。單繼承時構造函數 派生類名::派生類名(基類所需的形參,本類成員所需的形參):基類名(參數) {本類成員初始化賦值語句;}; 2。多繼承時構造函數 派生類名::派生類名(基類1形參,基類2形參,。。。。基類n形參,本類形參):基類名1

原创 c++文件操作

基於C的文件操作   在ANSI C中,對文件的操作分爲兩種方式,即流式文件操作和I/O文件操作,下面就分別介紹之。   一、流式文件操作    這種方式的文件操作有一個重要的結構FILE,FILE在stdio.h中定義如下:   t

原创 重載CLOCK類的++,--操作

#include<iostream> using namespace std; class CLOCK { int second; int minute; int hour; public: CLOCK() { second

原创 c++鏈表2

【雙向鏈表】 ①.建立一個雙向鏈表? 1       typedef struct DbNode 2       { 3               int data;       //節點數據 4                Db

原创 重載輸入>>,輸出<<操作符

1、istream& operator>>(istream& stream,className& obj)       {return stream;} 2、ostream& operator<<(ostream& stream,clas

原创 友元實現point+point

#include<iostream> using namespace std; class point11 { int x;int y; public: point11() { x=0;y=0; } point11(int

原创 sizeof 計算指針和數組

#include<iostream> using namespace std; int main() { int a[10]={1,2,3,4,5,6,7,8,9,0}; cout<<sizeof(a)/sizeof(a[0])

原创 二進制文件寫讀?

#include<iostream> #include<fstream> using namespace std; typedef struct PAYROLL { char name[30]; double salary; }pay

原创 抽象類

抽象類的一般形式 帶有純虛函數的類稱爲抽象類: class 類名 { virtual 類型 函數名(參數表)=0;//純虛函數 。。。。。。 } 1、抽象類爲抽象和設計的目的而建立,講有關的 數據和行爲組織在一個繼承層次中,保證派生類具

原创 同名覆蓋

#include<iostream> using namespace std; class aa { public: aa(){ } void fun() { cout<<"aa類的fun函數被調用"<<endl; } v