//#include
//using namespace std;
//int main(int argc, char *argv[])
//{
// cout << "Hello World!" << endl;
// return 0;
//}
//1.6.2 -1
//#include
//int main()
//{
// int x =8;
// int y =6;
// std::cout << std::endl;
// std::cout << x - y << " " << x * y <<" "<< x +y;
// std::cout << std::endl;
// return 0;
//}
//1.6.2 -3
//#include
//int main()
//{
// std::cout <<"Hello Buddd";
// return 0;
//}
//2.8.2 -1
//东西太简单,也得去做
//#include
//int main()
//{
// std::cout<<"IS";
//}
//2.8.2 -4
//#include
//using namespace std;//std is namespace !
//int a();
//int main()
//{
// a();
// return 0;
//}
//int a()
//{
// cout<<"AAAA"<
//enum YOURCARDS{ACE=43,JACK,QUEEN,KING}; //变量的类型 变量类型中的值 类比一下 比如int
//using namespace std;
//int main()
//{
// cout<<"QUEEN"<
//int main()
//{
// using namespace std;
// cout<<"size of int: "<
//int main()
//{
// const float PI =3.1415926;
// using namespace std;
// cout<<"PI: "<
//using namespace std;
//int main()
//{
// cout<<"This program will help you multiply two numbers"<>FirstNumber;//qt框架下不能用这个
// cout<<"Enter the second number: "<>SecondNumber;
// int MultiplicationResult =FirstNumber *SecondNumber;
// cout<
//using namespace std;
//int MultiplyNumbers()
//{
// cout<<"Enter the first number: "<>FirstNumber;//qt框架下不能用这个
// cout<<"Enter the second number: "<>SecondNumber;
// int MultiplicationResult =FirstNumber *SecondNumber;
// cout<
//using namespace std;
//int FirstNumber = 11;
//int SecondNumber = 12;
//int MultiplicationResult =0;
//int MultiplyNumbers()
//{
// //cout<<"Enter the first number: "<>FirstNumber;//qt框架下不能用这个
// //cout<<"Enter the second number: "<>SecondNumber;
// MultiplicationResult =FirstNumber *SecondNumber;
// cout<
//using namespace std;//放哪都行啊
//int main()
//{
// cout<<"Size of bool: "<
//using namespace std;
//int main()
//{
// auto Flag = true;
// auto Number = 250000;
// cout<<"Flag = "<
//int main()
//{
// using namespace std;
// const auto PI = 22/7;
// cout<<"PI is "<
//using namespace std;
//enum CardinalDirections
//{
// North =25,
// South,
// East,
// West
//};
//int main()
//{
// cout<
//#include
//using namespace std;
//int main()
//{
// vector DynArrNums;
// DynArrNums.push_back(1);
// DynArrNums.push_back(11111);
// DynArrNums.push_back(122);
// DynArrNums.push_back(122);
// cout<<"DynArrNums's size: "<
//using namespace std;
//int main()
//{
// char SayHello[]={'H','e','l','l','o','m','y','w','o','r','l','d','\0'};
//// SayHello[5] = '\0';
// //cout只能遇到空字符才能停止打印,如果没有空字符的话,程序将崩溃
// cout<
//#include
//#include//两个不一样
//using namespace std;
//int main()
//{
// cout<<"Enter a word NOT longer than 20 charachers"<
//#include
//using namespace std;
//int main()
//{
// string Greetings ("hello std::string!");
// cout<
//using namespace std;
//int main()
//{
// cout<<"hello" \
// <
//using namespace std;
//int main()
//{
// int MyInt =101;
// cout<<"Start value of integer being operated: "<
//using namespace std;
//int main()
//{
// int number =10;
// int Result = number<<1+1<<1;
// cout<<"Result: "<
//#include
//using namespace std;
//int main()
//{
// char Buffer[20]={'\0'};
// cout<<"Enter a line of text: "<
//using namespace std;
//int main()
//{
// cout<<"Enter two numbers"< Num2) ? Num1 : Num2;
// cout<<"Max: "<
//using namespace std;
//int main()
//{
// for (int Index =1; Index<2;Index++)
// {
// cout<<"AAA"<
//using namespace std;
//int FibonacciNum(int n)
//{
// if(n < 0){
// return -1;
// }else if(n == 0){
// return 0;
// }else if(n == 1){
// return 1;
// }else {
// return(FibonacciNum(n-1) + FibonacciNum(n-2));
// }
//}
//int main(){
// int num=10;
// if((num >= 0) && (num <= 50))
// {
// cout<
//using namespace std;
//int main()
//{
// while(-1)
// {
// cout<<"-1 is OK "<
//using namespace std;
//int main()
//{
// const int ARRAY_LEN = 5;
// int MyNumber[ARRAY_LEN]={-55,45,9889,0,45};
// for(int nIndex = ARRAY_LEN-1;nIndex>=0;--nIndex)
// cout<<"Number["<
//using namespace std;
//int main()
//{
// enum RainbowOfColor
// {
// Red =0,
// Orange,
// Yellow,
// Green_1,
// Blue,
// Green_2,
// Pink
// };
// cout<<"Please Input Color"<
//using namespace std;
//int GetFibNumber(int FibIndex)
//{
// if(FibIndex < 2)
// {
// return FibIndex;
// }
// else
// {
// return(GetFibNumber(FibIndex-2)+GetFibNumber(FibIndex-1));
// }
//}
//int main()
//{
// cout<<"Fibonacci"<
//using namespace std;
//void DisplayArray(int Number[],int length)
//{
// cout<
//using namespace std;
//const double PI = 3.14;
//void Area(double Radius,double& Result)
//{
// Result = PI*Radius*Radius;
//}
//int main()
//{
// double Radius = 10;
// double AreaFetched=0;
// Area(Radius,AreaFetched);
// cout<
//#include
//#include
//using namespace std;
//int main()
//{
// vector MyNumbers;
// MyNumbers.push_back(1);
// MyNumbers.push_back(2);
// MyNumbers.push_back(3);
// cout<
//using namespace std;
//int main()
//{
// int Age =30;
// const double PI =3.14;
// //use & to find the address in memory
// cout<<"Integer Age is at: "<< hex << &Age <
//using namespace std;
//int main()
//{
// int Age = 30;
// int* pInteger = &Age;
// //Displaying the value of pointer
// cout<<"Integer Age is at:"<
//using namespace std;
//int main()
//{
// int Age =30;
// int* pInteger = &Age;
// cout<<"pInteger points to Age now"<
//using namespace std;
//int main()
//{
// int Age =30;
// int DogsAge =9;
// cout<<"Integer Age= "<
//using namespace std;
//int main()
//{
// int DogsAge = 30;
// cout<<"Initialized DogsAge: "<
//using namespace std;
//int main()
//{
// int* pAge = new int;
// cout<<"Enter you dog's age: "<
//#include
//using namespace std;
//int main()
//{
// string Name ="zhengguoxian";
// int CharsToAllocate=Name.length()+1;
// cout<
//#include
//using namespace std;
//int main()
//{
// cout<<"How many chars you wish to enter?";
// string Name = "zhengguoxian";
// int InputNums = Name.length()+1;
// char* pNumbers = new char [InputNums];
// strcpy(pNumbers,Name.c_str());
// char* pCopy = pNumbers;
// cout<<"Successfully allocated memory for "<
//using namespace std;
//void CalcArea(const double* const pPI,const double* const pRadius, double* const pArea)
//{
// if(pPI&&pRadius&&pArea)
// {
// *pArea = (*pPI)*(*pRadius)*(*pRadius);
// }
//}
//int main()
//{
// const double PI=3.1416;
// double Radius =10;
// double Area;
// CalcArea(&PI,&Radius,&Area);
// cout<<"Area is = "<
//using namespace std;
//int main()
//{
// int MyNumbers[5];
// int* pNumbers = MyNumbers;
// cout<<"pNumbers = "<
//using namespace std;
//int main()
//{
// const int ARRAY_LEN = 5;
// int MyNumbers[ARRAY_LEN] ={24,-1,333,111,444};
// int* pNumbers = MyNumbers;
// cout<<"Displaying array using pointer syntax,operator*"<
//using namespace std;
//int main()
//{
// //bad
// int* pTemperature;
//// pTemperature = new int;
//// *pTemperature =30;
// cout<<"Temperature is "<<*pTemperature;
// delete pTemperature;
// return 0;
//}
////8.15
////异常处理,在new失败时妥善退出
//#include
//using namespace std;
//int main()
//{
// try
// {
// int* pAge =new int [1111111111111111];
// delete[] pAge;
// }
// catch(bad_alloc)
// {
// cout<<"Memory allocation failed.Ending program"<
//using namespace std;
//int main()
//{
// int* pAge = new(nothrow) int[1111111111111111111111111111111111111111111];
// cout<
//using namespace std;
//int main()
//{
// int Original =30;
// cout<<"Original = "<
//using namespace std;
//CalculateSquare(const int& Number, int& Result)
//{
// Result= Number*Number;
//}
//int main()
//{
// cout<<"Enter a number you wish to square: "<
//using namespace std;
//int main()
//{
// int* pNumber = new int;
// int* pNumberCopy = pNumber;
// *pNumberCopy = 30;
// cout<<*pNumberCopy;
//// delete pNumberCopy;
// delete pNumber;
//}
////9.1
//#include
//#include
//using namespace std;
//class Human
//{
//private:
// string Name;
// int Age;
//public:
// void SetName(string HumansName)
// {
// Name= HumansName;
// }
// void SetAge(int HumansAge)
// {
// Age = HumansAge;
// }
// void IntroduceSelf()
// {
// cout<<"I am "<
//using namespace std;
//class Human
//{
//private:
// int Age;
//public:
// void SetAge(int InputAge)
// {
// Age =InputAge;
// }
// int GetAge()
// {
// if(Age>30)
// return(Age-2);
// else
// return Age;
// }
//};
//int main()
//{
// Human FirstMan;
// FirstMan.SetAge(35);
// Human FirstWoman;
// FirstWoman.SetAge(22);
// cout<<"Age of FirstMan "<
//#include
//using namespace std;
//class Human
//{
//private:
// string Name;
// int Age;
//public:
// Human()
// {
// Age = 0;
// cout<<"Constructed an instance of class Human"<
//#include
//using namespace std;
//class Human
//{
//private:
// string Name;
// int Age;
//public:
// Human()
// {
// Age = 0;
// cout<<"Default constructor creates an instance of Human"<
//using namespace std;
//class Human
//{
//private:
// int Age;
// string Name;
//public:
// Human(string InputName = "Adam",int InputAge =25):Name(InputNamse),Age(InputAge)
// {
// cout<<"Constructed a Human called "<
//#include
//using namespace std;
//class MyString
//{
//private:
// char* Buffer;
//public:
// //Constructor
// MyString(const char* InitialInput)
// {
// if (InitialInput != NULL)
// {
// Buffer = new char [strlen(InitialInput)+1];
// strcpy(Buffer,InitialInput);
// }
// else
// {
// Buffer =NULL;
// }
// }
// //Destructor
// ~MyString()
// {
// cout<<"Invoking destructor,clearing up"<
//#include
//using namespace std;
//class MyString
//{
//private:
// char* Buffer;
//public:
// //constructor
// MyString(const char* InitialInput)
// {
// cout<<"Constructor: creating new MyString"<
//#include
//using namespace std;
//class President
//{
//private:
// President(){};
// President(const President&);
// const President& operator=(const President&);
// string Name;
//public:
// static President& GetInstance()
// {
// static President OnlyInstance;
// return OnlyInstance;
// }
// string GetName()
// {
// return Name;
// }
// void SetName(string InputName)
// {
// Name =InputName;
// }
//};
//int main()
//{
// President& Only =President::GetInstance();
// Only.SetName("ABraham Lincolin");
//// President Second;//因为构造函数私有 //定义一个对象
//// President* Third =new President();//因为构造函数私有//new 一个对象
//// Only = President::GetInstance();//对现有对象的拷贝,拷贝构造函数设为私有,就不能再main函数中使用
// cout<<"The name of the President is: ";
//// cout<
//using namespace std;
//class MonsterDB
//{
//private:
// ~MonsterDB() {};//private destructor
//public:
// static void DestroyInstance(MonsterDB* pInstance)
// {
// delete pInstance;
// }
//};
//int main()
//{
// MonsterDB* pMyDateBase = new MonsterDB();
// MonsterDB::DestroyInstance(pMyDateBase);
// cout<<"aaaaaa"<
//#include
//using namespace std;
//class MyString
//{
//private:
// char* Buffer;
//public:
// MyString(const char* InitialInput)
// {
// if(InitialInput != NULL)
// {
// Buffer = new char [strlen(InitialInput)+1];
// strcpy(Buffer,InitialInput);
// }
// else
// {
// Buffer = NULL;
// }
// }
// //拷贝构造函数
// MyString(const MyString& CopySource)
// {
// if(CopySource.Buffer != NULL)
// {
// Buffer = new char [strlen(CopySource.Buffer)+1];
// strcpy(Buffer,CopySource.Buffer);
// }
// else
// {
// Buffer = NULL;
// }
// }
// ~MyString()
// {
// if(Buffer != NULL)
// {
// delete [] Buffer;
// }
// }
// int GetLength()
// {
// return strlen(Buffer);
// }
// const char* GetString()
// {
// return Buffer;
// }
//};
//class Human
//{
//private:
// int Age;
// bool Gender;
// MyString Name;
//public:
// Human(const MyString& InputName, int InputAge, bool InputGender):Name(InputName),Age(InputAge),Gender(InputGender){}
// int GetAge()
// {
// return Age;
// }
//};
//int main()
//{
// MyString FirstMan("Adam");
// MyString FirstWoman("Eve");
// cout<<"sizeof(MyString) = "<
//#include
//using namespace std;
//class Human
//{
//private:
// string Name;
// int Age;
// friend void DisplayAge(const Human& Person);
//public:
// Human(string InputName,int InputAge)
// {
// Name = InputName;
// Age = InputAge;
// }
//};
//void DisplayAge(const Human& Person)
//{
// cout<
//#include
//using namespace std;
//class Human
//{
//private:
// string Name;
// int Age;
// friend class Utility;
//public:
// Human(string InputName, int InputAge)
// {
// Name = InputName;
// Age = InputAge;
// }
//};
//class Utility
//{
//public:
// //静态成员
// static void DisplayAge(const Human& Person)
// {
// cout<
//using namespace std;
//class Fish
//{
//public:
// bool FreshWaterFish;
// void Swim()
// {
// if(FreshWaterFish)
// cout<<"Swims in lake"<
//using namespace std;
//class Fish
//{
//protected:
// bool FreshWaterFish;
//public:
// void Swim()
// {
// if(FreshWaterFish)
// cout<<"Swims in lake "<
//using namespace std;
//class Fish
//{
//protected:
// bool FreshWaterFish;
//public:
// Fish(bool IsFreshWater): FreshWaterFish(IsFreshWater){}
// void Swim()
// {
// if(FreshWaterFish)
// cout<<"Swims in lake"<
//using namespace std;
//class Fish
//{
//private:
// bool FreshWaterFish;
//public:
// Fish(bool IsFreshWater): FreshWaterFish(IsFreshWater) {}
// void Swim()
// {
// if(FreshWaterFish)
// cout<<"Swims in lake"<
//using namespace std;
//class Fish
//{
//private:
// bool FreshWaterFish;
//public:
// Fish(bool IsFreshWater):FreshWaterFish(IsFreshWater) {}
// void Swim()
// {
// if(FreshWaterFish)
// cout<<"Swims in lake"<
//using namespace std;
//class Fish
//{
//public:
// void Swim()
// {
// cout<<"Fish swims ...!"<
//using namespace std;
//class FishDummyMember
//{
//public:
// FishDummyMember()
// {
// cout<<"FishDummyMember constructor"<
//using namespace std;
//class Motor
//{
//public:
// void SwitchIgnition()
// {
// cout<<"Ignition ON"<
//using namespace std;
//class Motor
//{
//public:
// void SwitchIgnition()
// {
// cout<<"Ignition ON"<
//using namespace std;
//class Mammal
//{
//public:
// Mammal()
// {
// cout<<"Mammal constructor"<
//using namespace std;
//class Fish
//{
//public:
// void Swim()
// {
// cout<<"Fish swims"<
using namespace std;
class Fish
{
public:
virtual void Swim()
{
cout<<"Fish swims"<
//using namespace std;
//class Fish
//{
//public:
// Fish()
// {
// cout<<"Fish constructor"<
//using namespace std;
//class Fish
//{
//public:
// Fish()
// {
// cout<<"Fish constructor"<
//using namespace std;
//class Fish
//{
//public:
// virtual void Swim()=0; //纯虚函数
//};
//class Tuna:public Fish
//{
//public:
// void Swim()
// {
// cout<<"Tuna swims fast in the sea"<
//using namespace std;
//class Animal
//{
//public:
// Animal()
// {
// cout<<"Animal constructor"<
//using namespace std;
//class Animal
//{
//public:
// Animal()
// {
// cout<<"Animal constructor"<
//using namespace std;
//class Shape
//{
//public:
// virtual double Area() =0;//纯虚函数,使基类变成抽象基类
// virtual void Print() =0;
//};
//class Circle:public Shape
//{
// double Radius;
//public:
// Circle(double inputRadius) :Radius(inputRadius) {}
// double Area()
// {
// return 3.1416*Radius*Radius;
// }
// void Print()
// {
// cout<<"Circle says hello"<
//using namespace std;
//class Date
//{
//private:
// int Day;
// int Month;
// int Year;
//public:
// Date(int InputDay,int InputMonth, int InputYear):Day(InputDay),Month(InputMonth),Year(InputYear) {};
// //???
// Date& operator ++ ()
// {
// ++Day;
// return *this;
// }
// Date& operator -- ()
// {
// --Day;
// return *this;
// }
// void DisplayDate()
// {
// cout<
//#include
//#include
//using namespace std;
//class Date
//{
//private:
// int Day;
// int Month;
// int Year;
// string DateInString;
//public:
// Date(int InputDay,int InputMonth, int InputYear):Day(InputDay),Month(InputMonth),Year(InputYear) {};
// operator const char*()
// {
// ostringstream formattedDate;
// formattedDate<
//#include
//using namespace std;
//class Date
//{
//private:
// int Day;
// int Month;
// int Year;
// string DateInString;
//public:
// Date(int InputDay,int InputMonth,int InputYear):Day(InputDay),Month(InputMonth),Year(InputYear) {};
// void DisplayDate()
// {
// cout< pDynamicAllocInteger(new int);
// //?? *(地址) = 值 &(变量) = 地址 有啥区别
// *pDynamicAllocInteger =42;
// cout<<"Integer value is "<<*pDynamicAllocInteger< pHoliday(new Date(25,11,2011));
// cout<<"The new instance of date contains: ";
// pHoliday->DisplayDate();
// int Age =30;
// //
// int* pInteger = &Age;
// cout<<*pInteger<
//using namespace std;
////???类似函数重载的功能 函数模板
//template
//class smart_pointer
//{
//private:
// T* m_pRawPointer;
//public:
// smart_pointer(T* pData):m_pRawPointer(pData) {};
// ~smart_pointer(){delete m_pRawPointer;}
// //???
// T& operator*() const
// {
// return *(m_pRawPointer);
// }
// //??? 一用这个->符号,我就调用这个函数吗 那是固定的格式吗
// T* operator-> () const
// {
// return m_pRawPointer;
// }
//};
//class Date
//{
//private:
// int Day,Month,Year;
// string DateString;
//public:
// Date(int InputDay,int InputMonth, int InputYear): Day(InputDay),Month(InputMonth),Year(InputYear) {};
// void DisplayDate()
// {
// cout< pDynamicInt(new int(43));
// cout<<"BBBB"<<*pDynamicInt< pDate(new Date(25,12,2011));
// cout<<"AAAA";
// pDate->DisplayDate();
// //这是一种
//// Date pDate(25,12,2011);
//// pDate.DisplayDate();
//// //第二种
//// Date* pDate(new Date(25,12,2011));
//// (*pDate).DisplayDate();
//// pDate->DisplayDate();//这个也行
//// int* pDynamicInt(new int(43));
//// cout<<"DDDD"<<*pDynamicInt<
//using namespace std;
//class Date
//{
//private:
// int Day, Month, Year;
//public:
// Date(int InputDay,int InputMonth, int InputYear):Day(InputDay),Month(InputMonth),Year(InputYear) {};
// Date operator+ (int DaysToAdd)
// {
// //???
// Date newDate (Day+DaysToAdd,Month,Year);
// return newDate;
// }
// Date operator- (int DaysToSub)
// {
// //???两个的表达的功能是一样的
//// return Date(Day-DaysToSub,Month,Year);
// Date newDate1 (Day-DaysToSub,Month,Year);
// return newDate1;
// }
// void DisplayDate()
// {
// cout<
//using namespace std;
//class Date
//{
//private:
// int Day,Month,Year;
//public:
// Date(int InputDay,int InputMonth,int InputYear):Day(InputDay),Month(InputMonth),Year(InputYear) {};
// void operator += (int DaysToAdd)
// {
// Day+=DaysToAdd;
// }
// void operator -= (int DaysToSub)
// {
// Day-=DaysToSub;
// }
// void DisplayDate()
// {
// cout<
//using namespace std;
//class Date
//{
//private:
// int Day,Month,Year;
//public:
// Date(int InputDay,int InputMonth, int InputYear): Day(InputDay),Month(InputMonth),Year(InputYear) {};
// //???
// bool operator == (const Date& compareTo)
// {
// return((Day == compareTo.Day)&&(Month == compareTo.Month)&&(Year==compareTo.Year));
// }
// //???
// bool operator != (const Date& compareTo)
// {
// return!(this->operator==(compareTo));
// }
// void DisplayDate()
// {
// cout<
//using namespace std;
//class Date
//{
//private:
// int Day,Month,Year;
//public:
// Date(int InputDay,int InputMonth,int InputYear): Day(InputDay),Month(InputMonth),Year(InputYear) {};
// bool operator == (const Date& compareTo)
// {
// return ((Day == compareTo.Day)&&(Month==compareTo.Month)&&(Year==compareTo.Year));
// }
// bool operator < (const Date& compareTo)
// {
// if(Year operator == (compareTo))
// return true;
// else
// return this->operator < (compareTo);
// }
// bool operator > (const Date& compareTo)
// {
// return !(this->operator <= (compareTo));
// }
// bool operator >=(const Date& compareTo)
// {
// if(this->operator == (compareTo))
// return true;
// else
// return this->operator > (compareTo);
// }
// bool operator !=(const Date& compareTo)
// {
// return !(this->operator == (compareTo));
// }
// void DisplayDate()
// {
// cout<Holiday2)
// cout<<"Holiday1>Holiday2"<=Holiday2)
// cout<<"Holiday1>=Holiday2"<
//#include
//using namespace std;
//class MyString
//{
//private:
// char* Buffer;
//public:
// MyString(const char* InitialInput)
// {
// if(InitialInput != NULL)
// {
// Buffer = new char [strlen(InitialInput)+1];
// strcpy(Buffer,InitialInput);
// }
// else
// {
// Buffer =NULL;
// }
// }
// //拷贝构造函数
// MyString(const MyString& CopySource);
// //复制赋值运算符
// //this 当前对象的地址
// //当前对象是???
// MyString& operator = (const MyString& CopySource)
// {
// if((this != &CopySource)&&(CopySource.Buffer != NULL))
// {
// if(Buffer !=NULL)
// delete [] Buffer;
// Buffer = new char [strlen(CopySource.Buffer)+1];
// strcpy(Buffer,CopySource.Buffer);
// }
// return *this;
// }
// ~MyString()
// {
// if(Buffer != Buffer)
// delete [] Buffer;
// }
// int GetLength()
// {
// return strlen(Buffer);
// }
// //目的:让cout显示类的对象
// operator const char*()
// {
// return Buffer;
// }
//};
//int main()
//{
// MyString String1("Hello");
// MyString String2("World");
// cout<<"Before assignment: "<
//#include
//using namespace std;
//class MyString
//{
//private:
// char* Buffer;
// //private default constructor
//// MyString(){}//可以不写
//public:
// //constructor
// MyString(const char* InitialInput)
// {
// if(InitialInput != NULL)
// {
// //为什么要加1呢
// Buffer = new char [strlen(InitialInput)+1];
// strcpy(Buffer,InitialInput);
// }
// else
// Buffer = NULL;
// }
// //copy constructor
// MyString(const MyString& CopySource);
// //copy assignment operator
// MyString& operator=(const MyString& CopySource);
// //下标运算符 两个const啥意思呢 后一个const 禁止修改了类的成员属性
// const char& operator[] (int Index) const
// {
// if(Index
//#include
//using namespace std;
//class CDisplay
//{
//public:
// void operator () (string Input) const
// {
// cout<
//#include
//using namespace std;
//class MyString
//{
//private:
// char* Buffer;
// //private default constructor
// //为啥要变为私有呢???
// //我认为无所谓
//public:
// MyString(): Buffer(NULL)
// {
// cout<<"Default constructor called"<
//using namespace std;
//class Fish
//{
//public:
// //虚函数 例子11.2
// virtual void Swim()
// {
// cout<<"Fish swims in water"<(InputFish);
// cout<<"pIsTuna"<BecomeDinner();
// }
// Carp* pIsCarp = dynamic_cast(InputFish);
// cout<<"pIsCarp"<Talk();
// }
// cout<<"Verifying type using virtual Fish::Swim: "<Swim();
//}
//int main()
//{
// Carp myLunch;
// Tuna myDinner;
// DetectFishType(&myDinner);
// cout<
//#include
//using namespace std;
//#define ARRAY_LENGTH 25
//#define PI 3.1416
//#define MY_DOUBLE double
//#define FAV_WHISKY "Jack Daniels"
//int main()
//{
// int MyNumbers[ARRAY_LENGTH] ={0,1,2,2};
// cout<<"Array's length: "<
//#include
//using namespace std;
//#define SQUARE(x) ((x)*(x))
//#define PI 3.1416
//#define AREA_CIRCLE(r) (PI*(r)*(r))
//#define MAX(a,b) (((a)>(b))?(a):(b))
//#define MIN(a,b) (((a)<(b))?(a):(b))
//int main()
//{
//// cout<<"Enter a integer: "<
//#include
//using namespace std;
//template
//const Type& GetMax(const Type& value1, const Type& value2)
//{
// if(value1 > value2 )
// return value1;
// else
// return value2;
//}
//template
//void DisplayComparision(const Type& value1, const Type& value2)
//{
// cout<
//using namespace std;
//template
//class HoldsPair
//{
//private:
// T1 Value1;
// T2 Value2;
//public:
// HoldsPair(const T1& value1,const T2& value2)
// {
// Value1 = value1;
// Value2 = value2;
// }
// const T1& GetFirstValue() const
// {
// return Value1;
// }
// const T2& GetSecondValue() const
// {
// return Value2;
// }
//};
//int main()
//{
// HoldsPair <> mIntFloatPair(300,10.09);
// //类<指定模板T1,T2是什么> 对象(传入构造函数参数);
// HoldsPair mShortStringPair(25,"Learn templates,love C++");
// //
// cout<<"The first object contains -"<
//using namespace std;
//template
//class TestStatic
//{
//public:
// static T StaticValue;
//};
//template T TestStatic::StaticValue;
//int main()
//{
// TestStatic Int_Year;
// Int_Year.StaticValue =2011;
// TestStatic Int_2;
// TestStatic Double1;
// TestStatic Double2;
// Double2.StaticValue =1011.11;
// cout<<"Double1.StaticValue: "<
//using namespace std;
//template
//class EverytingButInt
//{
//public:
// EverytingButInt()
// {
// static_assert(sizeof(T) != sizeof(int),"No int please!");
// cout<<"OK"< test;
//}
////14.7.2 -1
//#include
//using namespace std;
//#define SQUARE(x,y) ((x)*(y))
//int main()
//{
//// cout<<"Enter a integer: "<
//using namespace std;
//template
//Type SquareTwoNumber(const Type& value1, const Type& value2)
//{
// return (value1*value2);
//}
//template
//void DisplayComparision(const Type& value1, const Type& value2)
//{
// cout<
//using namespace std;
//template
//void SwapTwoNumber( T& value1, T& value2)
//{
// T value3;
// value3 =value1;
// value1 =value2;
// value2 =value3;
//}
//int main()
//{
// int Int1 = 10,Int2 = 11;
// SwapTwoNumber(Int1,Int2);
// cout<<"Int1 :"<
//#include
//#include
//using namespace std;
//int main()
//{
// vector vecIntegerArray;
// vecIntegerArray.push_back(50);
// vecIntegerArray.push_back(2991);
// vecIntegerArray.push_back(23);
// vecIntegerArray.push_back(9999);
// //???vector::iterator 是每个元素的类型
// //vecIntegerArray.end 最后一个元素的地址再加1
// auto iArrayWalker = vecIntegerArray.begin();
// cout<<"show *iArrayWalker"<<*iArrayWalker<::iterator iElement = find(vecIntegerArray.begin(), vecIntegerArray.end(),9999);
// auto iElement = find(vecIntegerArray.begin(), vecIntegerArray.end(),9999);
// if(iElement != vecIntegerArray.end())
// {
// int Position = distance(vecIntegerArray.end(),iElement);
// cout<<"Value"<<*iElement;
// cout<<"found in the vector at position"<
//#include
////using namespace std;
//int main()
//{
// using namespace std;
// const char* constCStyleString = "Hello String";
// cout<<"Constant string is: "<
//#include
//using namespace std;
//int main()
//{
// string strSTLString ("hello string");
// cout<<"SSSSSSSSSSSSSSSSSSSSSSS"<
//#include
//int main()
//{
// using namespace std;
// string strSample1("Hello");
// string strSample2("String!");
// strSample1 +=strSample2;
// cout<
//#include
//using namespace std;
//int main()
//{
// string strSample("Good day String! today is beautiful!");
// cout<<"The sample string is: "<
//#include
//#include
//using namespace std;
//int main()
//{
// string strSample("hello SSSSString!String! wake up to a beautiful day!");
// cout<
//#include
//#include
//using namespace std;
//int main()
//{
// string strSample("Hello String! We will reverse you");
// cout<
//#include
//#include
//using namespace std;
//int main()
//{
// string strSample("hello my world");
// cout<
//#include
//#include
//int main()
//{
// using namespace std;
// cout<<"..SRART.."<
//#include
//using namespace std;
//int GetNumCharacters(string& strInput, char chToFind)
//{
// int nNumCharactersFound =0;
// //??size_t 类似于int 类型
// size_t nCharOffset = strInput.find(chToFind);
// //string::npos 是一个非常大的数值
//// cout<
//#include
//#include
//int main()
//{
// using namespace std;
// cout<<"..START.."<
//#include
//using namespace std;
//int main()
//{
// string str1 = "I";
// string str2 = "LOVE";
// string str3 = "YOU";
// string strOutput = str1 + ' ' + str2 + ' ' + str3;
// cout<
//int main()
//{
// std::vector vecIntegers;
// //这个向量初始化为10个元素,可以更大
// std::vector vecWithTenElements(10);
// //10个元素,每个元素初始化为90
// std::vector vecWithTenInitializedElements(10,90);
// //将另一个向量进行复制
// std::vector vecArrayCopy(vecWithTenInitializedElements);
// //将另一个向量的一些元素进行复制
// std::vector vecSomeElementsCopied(vecWithTenElements.cbegin(),vecWithTenElements.cbegin()+5);
//}
////17.2使用push_back()插入元素
//#include
//#include
//using namespace std;
//int main()
//{
// vector vecIntegers;
// vecIntegers.push_back(50);
// vecIntegers.push_back(11);
// vecIntegers.push_back(10);
// vecIntegers.push_back(91);
// vecIntegers.push_back(10);
// vecIntegers.push_back(81);
// cout<<"OUTPUT"<
//#include
//using namespace std;
//void DisplayVector(const vector& vecInput)
//{
// for(auto iElement = vecInput.cbegin();iElement != vecInput.cend(); ++iElement)
// {
// cout<<*iElement<<" ";
// }
//}
//int main()
//{
// //向量初始化为4个元素,每个元素的值为90
// vector vecIntegers(4,90);
// DisplayVector(vecIntegers);
// cout< vecAnother(4,30);
// //在第二个位置插入另一个向量
// vecIntegers.insert(vecIntegers.begin()+1,vecAnother.begin(),vecAnother.end());
// DisplayVector(vecIntegers);
//}
////17.4
//访问向量元素并修改
//#include
//#include
//using namespace std;
//int main()
//{
// vector vecIntegerArray;
// vecIntegerArray.push_back(11);
// vecIntegerArray.push_back(12);
// vecIntegerArray.push_back(123);
// vecIntegerArray.push_back(11111);
// for(size_t Index =0;Index
//#include
//using namespace std;
//int main()
//{
// vector vecIntegers;
// vecIntegers.push_back(11);
// vecIntegers.push_back(12);
// vecIntegers.push_back(1111);
// vecIntegers.push_back(12221);
// vector::iterator iElementLocator = vecIntegers.begin();
// while(iElementLocator != vecIntegers.end())
// {
// cout<<*iElementLocator<<" ";
// ++iElementLocator;
// }
//}
////17.6
////使用pop_back 删除最后一个元素
//#include
//#include
//using namespace std;
//template
//void DisplayVector(const vector& vecInput)
//{
// for(auto iElement = vecInput.cbegin();iElement != vecInput.cend();iElement++)
// {
// cout<<*iElement<<" ";
// }
//}
//int main()
//{
// vector vecIntegers;
// vecIntegers.push_back(1);
// vecIntegers.push_back(12);
// vecIntegers.push_back(1111);
// vecIntegers.push_back(2222);
// DisplayVector(vecIntegers);
// cout<
//#include
//using namespace std;
//int main()
//{
// vector vecIntegers(5);
// cout<
//#include
//#include
//using namespace std;
//int main()
//{
// deque dqIntegers;
// dqIntegers.push_back(1);
// dqIntegers.push_back(12);
// dqIntegers.push_back(12);
// //在数组的开头插入元素
// dqIntegers.push_front(1);
// dqIntegers.push_front(2);
// dqIntegers.push_front(3);
// for(size_t nCount = 0;nCount
//#include
//using namespace std;
//int main()
//{
// vector vecData;
// vecData.push_back(11);
// vecData.push_back(12);
// vecData.push_back(13);
// cout<
//#include
//int main()
//{
// using namespace std;
// list listIntegers;
// list listWith10Integers(10);
// list listWith4IntegerEach99(10,99);
// list listCopyAnother(listWith4IntegerEach99);
// vector vecIntegers(10,2011);
// list listContainsCopyOfAnother(vecIntegers.cbegin(),vecIntegers.cend());
// return 0;
//}
////18.2
////使用push_back和push_front插入元素
//#include
//#include
//using namespace std;
//template