自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 收藏
  • 关注

转载 C++容器类(来自yeahask的博客http://blog.sina.com.cn/yeahask )

C++容器类C++中的容器类包括“顺序存储结构”和“关联存储结构”,前者包括vector,list,deque等;后者包括set,map,multiset,multimap等。若需要存储的元素数在编译器间就可以确定,可以使用数组来存储,否则,就需要用到容器类了。 1、vector连续存储结构,每个元素是在内存上是连续的;支持高效的随机访问和在尾端插入/删除操作,但其他位置的

2016-03-11 20:18:47 1003

原创 第十五章编程练习(1)

TV.h#pragma once#ifndef TV_H_#define TV_H_//class Remote; #使用前向声明 让TV类知道Remote是一个类class Tv {private: int state; int volume; int maxchannel; int channel; int mode; int input; public: fr

2016-03-06 14:37:29 317

原创 第十四章编程练习(5)

这里我充斥着大量的内联函数,这样看起来貌似比较乱?还是阅读性更好?ARSTR.h#pragma once#ifndef ABSTR_H_#define ABSTR_H_#include #include class abstr_emp {private: std::string fname; std::string lname; std::string job;publ

2016-03-05 22:52:20 529

原创 第十四章编程练习(4)

PERSIN.h#pragma once#ifndef PERSON_H_#define PERSON_H_#include class Person {private: std::string fname; std::string sname;public: Person(); Person(const std::string & f, const std::string

2016-03-05 19:15:23 582

原创 第十四章编程练习(3)

建立一个容器类模板,然后使用Worker作为容器类参数QUEUETP.h#pragma once#ifndef WORKERMI_H_#define WORKERMI_H_#includetemplate//创建一个容器类模板class QueueTP{private: struct Node { T item; Node * next; }; Node * front;

2016-03-04 20:37:24 548

原创 第十四章编程练习(2)

WINE.h#pragma once#ifndef WINE_H_#define WINE_H_#include#includetemplate class Pair {private: T1 a; T2 b;public: Pair(); void setfist(const T1 & y) { a = y; }; void setscond(const T2 &

2016-03-03 13:12:44 375

原创 第十四章编程练习(1)

WINE.h#pragma once#ifndef WINE_H_#define WINE_H_#include#includetemplate class Pair {private: T1 a; T2 b;public: Pair(); void setfist(const T1 & y) { a = y; }; void setscond(const T2 &

2016-02-28 21:34:07 351 1

原创 第十三章编程练习(2)

Classic.h#pragma once#ifndef Classic_H_#define Classic_H_class Cd {private: char * performers; char * label; int selections; double playtime;public: Cd(char * s1="blank", char * s2="null"

2016-02-28 18:52:23 296

原创 第十三章编程练习(1)

Classic.h#pragma once#ifndef Classic_H_#define Classic_H_class Cd {private: char performers[50]; char label[20]; int selections; double playtime;public: Cd(char * s1, char * s2, int n, dou

2016-02-27 19:21:18 279

原创 第十三章编程练习(4)

PORT.h#pragma once#ifndef PORT_H_#define PORT_H_#include using namespace std;class Port {private: char * brand; char style[20]; int bottles;public: Port(const char * br = "none", int b =

2016-02-26 18:16:38 251

原创 第十三章编程练习(3)

brass.h#pragma once#ifndef BRASS_H_#define BRASS_H_#include class Brass{private: std::string label; int rating;public: Brass(const std::string l = "null", int r = 0); Brass(const Brass &

2016-02-26 15:32:47 272

原创 第十二章编程练习(6)

头文件和实现函数和上一题一样,这里就不列出来了这里是理想化的,也就是刚好上一名顾客的处理时间还剩1分钟时,就马上有顾客进入队列当两台ATM的顾客剩余处理时间都是1分钟时,就有两名顾客分别进入第一和第二个队列main.cpp#include "queue.h"#include #include #include const int MIN_PER_HR = 60;int m

2016-02-25 00:19:30 246

原创 第十二章编程练习(5)

QUEUE.h#pragma once#ifndef QUEUE_H_#define QUEUE_H_class Customer {private: int processtime;//顾客所需的服务时间public: Customer() { processtime = 0; }; void set(); int ptime()const { return process

2016-02-22 21:08:10 265

原创 第十二章编程练习(4)

STACK.h#pragma once#ifndef STACK_H_#define STACK_H_typedef unsigned long Item;class Stack {private: enum { MAX = 10 }; Item * pitems; int size;//需要创建的数组大小 int top;//数组下标public: Stack(int

2016-02-19 22:45:32 287

原创 第十二章编程练习(3)

STOCK.h#pragma once#ifndef STOCK_H_#define STOCK_H_#include class Stock {private: char * str; int shares; double share_val; double total_val; void set_tot() { total_val = shares * share_va

2016-02-18 20:51:27 302

原创 第十二章编程练习(2)

string2.h#pragma once#ifndef string2_H_#define string2_H_#include using std::ostream;using std::istream;class String{private: char * str; int len; static int num_strings; static const int

2016-02-17 19:38:58 259

原创 第十二章编程练习(1)

COW.H#pragma once#ifndef COW_H_#define COW_H_class Cow {private: char name[20]; char * hobby; double weight;public: Cow(); Cow(const char * nm, const char * ho, double wt); Cow(const Cow

2016-02-17 16:06:41 382

原创 第十一章编程练习(7)

complex0.h#pragma once#ifndef complex0_H_#define complex0_H_#include class complex {private: double s; double x;public: complex(); complex(double a, double b); complex operator +(const co

2016-02-11 21:38:28 292

原创 第十一章编程练习(6)

list.h#pragma once#ifndef list_H_#define list_H_#include using namespace std;class Stonewt {private: static const int Lbs_per_stn = 14; enum Mode { BP, INT_GBP, FLOAT_GBP }; Mode mode; int

2016-02-11 19:16:15 465

原创 第十一章编程练习(5)

list.h#pragma once#ifndef list_H_#define list_H_#include using namespace std;class Stonewt {private: static const int Lbs_per_stn = 14; enum Mode { BP, INT_GBP, FLOAT_GBP }; Mode mode; int

2016-02-11 17:10:14 261

原创 第十一章编程练习(4)

list.h# pragma once# ifndef list_H_# define list_H_#include class Time {private: int hours; int minutes;public: Time(); Time(int h, int m); void AddMin(int m); void AddHt(int

2016-02-09 21:02:38 196

原创 第十一章编程练习(3)

list.h#pragma once#ifndef list_H_#define list_H_#include namespace VECTOR { class Move { public: enum move { RECH, POL }; private: double x; //分量 double y; //分量 //double ma

2016-02-09 14:48:20 259

原创 第十一章编程练习(2)

list.h#pragma once#ifndef list_H_#define list_H_#include namespace VECTOR { class Move { public: enum move { RECH, POL }; private: double x; //分量 double y; //分量 //double ma

2016-02-09 14:20:10 274

原创 第十一章编程练习(1)

list.h#pragma once#ifndef list_H_#define list_H_#include namespace VECTOR { class Move { public: enum move { RECH, POL }; private: double x; //分量 double y; //分量 double mag;

2016-02-08 22:50:05 264

原创 第十章编程练习(7)

ff.h#pragma once#ifndef ff_H_#define ff_H_class Plorg {private: char name[19]; int cl;public: Plorg(char p_name[19] = "Plorga", int n = 50); void setcl(int n); void showpl()const;};#endi

2016-02-05 19:37:50 260

原创 第十章编程练习(6)

#pragma once#ifndef ff_H_#define ff_H_class Move {private: double x; double y;public: Move(double a = 0,double b = 0);//初始化x,y void showmove()const; Move add(const Move & m);//把m对象的数据与调用对象的值

2016-02-03 16:22:52 435

原创 第十章编程练习(5)

#pragma once#ifndef ff_H_#define ff_H_struct customer { char fullname[35]; double payment;};typedef customer Item;class Stack {private: enum{MAX=10}; Item items[MAX]; int top;public: Sta

2016-02-03 15:18:40 226

原创 第十章编程练习(4)

ff.h#pragma once#ifndef ff_H_#define ff_H_namespace SALES{ class  Sudio{ private:  static const int QUARTER = 4;  struct Sales  {   double sales[QUARTER];   double average;

2016-02-03 00:22:53 314

原创 第十章编程练习(3)

ff.h#pragma once#ifndef ff_H_#define ff_H_const int MAX = 20;class Sudio {private: struct golf { char fullname[MAX]; int handicap; }go;public: Sudio(); ~Sudio(); Sudio(char * ch,int n

2016-02-02 18:43:05 312

原创 第十章编程练习(2)

ff.h#pragma once#ifndef ff_H_#define ff_H_#include using namespace std;class Person {private: static const int LIMIT = 25; string lname; char fname[LIMIT];public: Person(){lname = "", fna

2016-02-01 23:34:22 272

原创 第十章编程练习(1)

ff.h#pragma once#ifndef ff_H_#define ff_H_#include using namespace std;const int MAX = 6;class Sudio{ string name; char number[MAX]; double money;public: Sudio(); ~Sudio(); void set(cons

2016-02-01 22:44:54 273

原创 第九章编程练习(3)

#include #include using namespace std;struct chaff { char dross[20]; int slag;};const int data_size = 2;void setstr(chaff & ch);void showstr(const chaff & ch);int main(){ chaff *ps = new c

2016-01-27 20:46:51 266

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除