亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? chap25.lst

?? Borland C++ Builder The Complete Reference 例程源代碼
?? LST
字號:
listing 1
// Function template example. 
#include <iostream> 
using namespace std; 
 
// This is a function template. 
template <class X> void swapargs(X &a, X &b) 
{ 
  X temp; 
 
  temp = a; 
  a = b; 
  b = temp; 
} 
 
int main() 
{ 
  int i=10, j=20; 
  float x=10.1, y=23.3; 
  char a='x', b='z'; 
 
  cout << "Original i, j: " << i << ' ' << j << endl; 
  cout << "Original x, y: " << x << ' ' << y << endl; 
  cout << "Original a, b: " << a << ' ' << b << endl; 
 
  swapargs(i, j); // swap integers 
  swapargs(x, y); // swap floats 
  swapargs(a, b); // swap chars 
 
  cout << "Swapped i, j: " << i << ' ' << j << endl; 
  cout << "Swapped x, y: " << x << ' ' << y << endl; 
  cout << "Swapped a, b: " << a << ' ' << b << endl; 
 
  return 0; 
}

listing 2
template <class X> void swapargs(X &a, X &b)

listing 3
#include <iostream> 
using namespace std; 
 
template <class type1, class type2> 
void myfunc(type1 x, type2 y) 
{ 
  cout << x << ' ' << y << endl; 
} 
 
int main() 
{ 
  myfunc(10, "hi"); 
  myfunc(0.23, 10L); 
 
  return 0; 
} 


listing 4
// Overriding a template function. 
#include <iostream> 
using namespace std; 
 
template <class X> void swapargs(X &a, X &b) 
{ 
  X temp; 
 
  temp = a; 
  a = b; 
  b = temp; 
} 
 
// This overrides the generic version of swap(). 
void swapargs(int &a, int &b) 
{ 
  int temp; 
 
  temp = a; 
  a = b; 
  b = temp; 
  cout << "Inside overloaded swapargs(int &, int &).\n"; 
} 
 
int main() 
{ 
  int i=10, j=20; 
  float x=10.1, y=23.3; 
  char a='x', b='z'; 
 
  cout << "Original i, j: " << i << ' ' << j << endl; 
  cout << "Original x, y: " << x << ' ' << y << endl; 
  cout << "Original a, b: " << a << ' ' << b << endl; 
 
  swapargs(i, j); // this calls the explicitly overloaded swapargs() 
  swapargs(x, y); // swap floats 
  swapargs(a, b); // swap chars 
 
  cout << "Swapped i, j: " << i << ' ' << j << endl; 
  cout << "Swapped x, y: " << x << ' ' << y << endl; 
  cout << "Swapped a, b: " << a << ' ' << b << endl; 
 
  return 0; 
}

listing 5
// Use new-style specialization syntax 
template<> void swapargs<int>(int &a, int &b) 
{ 
  int temp; 
 
  temp = a; 
  a = b; 
  b = temp; 
  cout << "Inside specialized swapargs(int &, int &).\n"; 
}

listing 6
// Overload a function template declaration. 
#include <iostream> 
using namespace std; 
 
// First version of f() template. 
template <class X> void f(X a) 
{ 
  cout << "Inside f(X a)\n a = " << a << endl; 
} 
 
// Second version of f() template. 
template <class X, class Y> void f(X a, Y b) 
{ 
  cout << "Inside f(X a, Y b)\n a = " << a << "\n b = " << b << endl; 
} 
 
int main() 
{ 
  f(10);     // calls f(X) 
  f(10, 20); // calls f(X, Y) 
 
  return 0; 
}

listing 7
#include <iostream> 
#include <cmath> 
using namespace std; 
 
void myfunc(int i) 
{ 
  cout << "value is: " << i << "\n"; 
} 
 
void myfunc(double d) 
{ 
  double intpart; 
  double fracpart; 
 
  fracpart = modf(d, &intpart); 
  cout << "Fractional part: " << fracpart; 
  cout << "\n"; 
  cout << "Integer part: " << intpart; 
} 
 
int main() 
{ 
  myfunc(1); 
  myfunc(12.2); 
 
  return 0; 
}

listing 8
// Demonstrate a generic stack class. 
#include <iostream> 
using namespace std; 
 
const int SIZE = 100; 
 
// This creates the generic class stack. 
template <class SType> class stack { 
  SType stck[SIZE]; 
  int tos; 
public: 
  stack(); 
  ~stack(); 
  void push(SType i); 
  SType pop(); 
}; 
 
// stack's constructor function. 
template <class SType> stack<SType>::stack() 
{ 
  tos = 0; 
  cout << "Stack Initialized\n"; 
} 
 
/* stack's destructor function. 
   This function is not required.  It is included 
   for illustration only. */ 
template <class SType> stack<SType>::~stack() 
{ 
  cout << "Stack Destroyed\n"; 
} 
 
// Push an object onto the stack. 
template <class SType> void stack<SType>::push(SType i) 
{ 
  if(tos==SIZE) { 
    cout << "Stack is full.\n"; 
    return; 
  } 
  stck[tos] = i; 
  tos++; 
} 
 
// Pop an object off the stack. 
template <class SType> SType stack<SType>::pop() 
{ 
  if(tos==0) { 
    cout << "Stack underflow.\n"; 
    return 0; 
  } 
  tos--; 
  return stck[tos]; 
} 
 
int main() 
{ 
  stack<int> a; // create integer stack 
  stack<double> b; // create a double stack 
  stack<char> c; // create a character stack 
 
  int i; 
 
  // use the integer and double stacks 
  a.push(1); 
  b.push(99.3); 
  a.push(2); 
  b.push(-12.23); 
 
  cout << a.pop() << " "; 
  cout << a.pop() << " "; 
  cout << b.pop() << " "; 
  cout << b.pop() << "\n"; 
 
  // demonstrate the character stack 
  for(i=0; i<10; i++) c.push((char) 'A'+i); 
  for(i=0; i<10; i++) cout << c.pop(); 
  cout << "\n"; 
 
  return 0; 
}

listing 9
stack<int> a; // create integer stack 
stack<double> b; // create a double stack 
stack<char> c; // create a character stack

listing 10
stack<char *> chrptrstck;

listing 11
struct addr { 
  char name[40]; 
  char street[40]; 
  char city[30]; 
  char state[3]; 
  char zip[12]; 
}

listing 12
stack<addr> obj;

listing 13
/* This example uses two generic data types in a 
   class definition. 
*/ 
#include <iostream> 
using namespace std; 
 
template <class Type1, class Type2> class myclass 
{ 
  Type1 i; 
  Type2 j; 
public: 
  myclass(Type1 a, Type2 b) { i = a; j = b; } 
  void show() { cout << i << ' ' << j << '\n'; } 
}; 
 
int main() 
{ 
  myclass<int, double> ob1(10, 0.23); 
  myclass<char, char *> ob2('X', "This is a test"); 
 
  ob1.show(); // show int, double 
  ob2.show(); // show char, char * 
  
  return 0; 
}

listing 14
// A simple exception handling example. 
#include <iostream> 
using namespace std; 
 
int main() 
{ 
  cout << "Start\n"; 
 
  try { // start a try block 
    cout << "Inside try block\n"; 
    throw 100; // throw an error 
    cout << "This will not execute"; 
  } 
  catch (int i) { // catch an error 
    cout << "Caught an exception -- value is: "; 
    cout << i << "\n"; 
  } 
 
  cout << "End"; 
 
  return 0; 
}

listing 15
// This example will not work. 
#include <iostream> 
using namespace std; 
 
int main() 
{ 
  cout << "Start\n"; 
 
  try { // start a try block 
    cout << "Inside try block\n"; 
    throw 100; // throw an error 
    cout << "This will not execute"; 
  } 
  catch (double i) { // Won't work for an int exception 
    cout << "Caught an exception -- value is: "; 
    cout << i << "\n"; 
  } 
 
  cout << "End"; 
 
  return 0; 
}

listing 16
/* Throwing an exception from a function outside the 
   try block.  
*/ 
#include <iostream> 
using namespace std; 
 
void Xtest(int test) 
{ 
  cout << "Inside Xtest, test is: " << test << "\n"; 
  if(test) throw test; 
} 
 
int main() 
{ 
  cout << "Start\n"; 
 
  try { // start a try block 
    cout << "Inside try block\n"; 
    Xtest(0); 
    Xtest(1); 
    Xtest(2); 
  } 
  catch (int i) { // catch an error 
    cout << "Caught an exception -- value is: "; 
    cout << i << "\n"; 
  } 
 
  cout << "End"; 
 
  return 0; 
}

listing 17
#include <iostream> 
using namespace std; 
 
// A try/catch can be inside a function other than main(). 
void Xhandler(int test) 
{ 
  try{ 
    if(test) throw test; 
  } 
  catch(int i) { 
    cout << "Caught Exception #: " << i << '\n'; 
  } 
} 
 
int main() 
{ 
  cout << "Start\n"; 
 
  Xhandler(1); 
  Xhandler(2); 
  Xhandler(0); 
  Xhandler(3); 
 
  cout << "End"; 
 
  return 0; 
} 


listing 18
// Catching class type exceptions. 
#include <iostream> 
#include <cstring> 
using namespace std; 
 
class MyException { 
public: 
  char str_what[80]; 
  int what; 
 
  MyException() { *str_what = 0; what = 0; } 
 
  MyException(char *s, int e) { 
    strcpy(str_what, s); 
    what = e; 
  } 
}; 
 
int main() 
{ 
  int i; 
 
  try { 
    cout << "Enter a positive number: "; 
    cin >> i; 
    if(i<0) 
      throw MyException("Not Positive", i);  
  } 
  catch (MyException e) { // catch an error 
    cout << e.str_what << ": "; 
    cout << e.what << "\n"; 
  } 
 
  return 0; 
}

listing 19
#include <iostream> 
using namespace std; 
 
// Different types of exceptions can be caught. 
void Xhandler(int test) 
{ 
  try{ 
    if(test) throw test; 
    else throw "Value is zero"; 
  } 
  catch(int i) { 
    cout << "Caught Exception #: " << i << '\n'; 
  } 
  catch(char *str) { 
    cout << "Caught a string: "; 
    cout << str << '\n'; 
  } 
} 
 
int main() 
{ 
  cout << "Start\n"; 
 
  Xhandler(1); 
  Xhandler(2); 
  Xhandler(0); 
  Xhandler(3); 
 
  cout << "End"; 
 
  return 0; 
}

listing 20
// Catching derived classes. 
#include <iostream> 
using namespace std; 
 
class B { 
}; 
 
class D: public B { 
}; 
 
int main() 
{ 
  D derived; 
 
  try { 
    throw derived; 
  } 
  catch(B b) { 
    cout << "Caught a base class.\n"; 
  } 
  catch(D d) { 
    cout << "This won't execute.\n"; 
  } 
 
  return 0; 
}

listing 21
// This example catches all exceptions. 
#include <iostream> 
using namespace std; 
 
void Xhandler(int test) 
{ 
  try{ 
    if(test==0) throw test; // throw int 
    if(test==1) throw 'a'; // throw char 
    if(test==2) throw 123.23; // throw double 
  } 
  catch(...) { // catch all exceptions 
    cout << "Caught One!\n"; 
  } 
} 
 
int main() 
{ 
  cout << "Start\n"; 
 
  Xhandler(0); 
  Xhandler(1); 
  Xhandler(2); 
 
  cout << "End"; 
 
  return 0; 
} 


listing 22
// Restricting function throw types. 
#include <iostream> 
using namespace std; 
 
// This function can only throw ints, chars, and doubles. 
void Xhandler(int test) throw(int, char, double) 
{ 
  if(test==0) throw test; // throw int 
  if(test==1) throw 'a'; // throw char 
  if(test==2) throw 123.23; // throw double 
} 
 
int main() 
{ 
  cout << "start\n"; 
 
  try{ 
    Xhandler(0); // also, try passing 1 and 2 to Xhandler() 
  } 
  catch(int i) { 
    cout << "Caught an integer\n"; 
  } 
  catch(char c) {  
    cout << "Caught char\n"; 
  } 
  catch(double d) {  
    cout << "Caught double\n"; 
  } 
 
  cout << "end"; 
 
  return 0; 
}

listing 23
// This function can throw NO exceptions! 
void Xhandler(int test) throw() 
{ 
  /* The following statements no longer work.  Instead, 
     they will cause an abnormal program termination. */ 
  if(test==0) throw test;  
  if(test==1) throw 'a';  
  if(test==2) throw 123.23;  
}

listing 24
// Example of "rethrowing" an exception. 
#include <iostream> 
using namespace std; 
 
void Xhandler() 
{ 
  try { 
    throw "hello"; // throw a char * 
  } 
  catch(char *) { // catch a char * 
    cout << "Caught char * inside Xhandler\n"; 
    throw ; // rethrow char * out of function 
  } 
} 
 
int main() 
{ 
  cout << "Start\n"; 
 
  try{ 
    Xhandler(); 
  } 
  catch(char *) { 
    cout << "Caught char * inside main\n"; 
  } 
 
  cout << "End"; 
 
  return 0; 
}

listing 25
// Set a new terminate handler. 
#include <iostream> 
#include <cstdlib> 
#include <exception> 
using namespace std; 
 
void my_Thandler() { 
  cout << "Inside new terminate handler\n"; 
  abort(); 
} 
 
int main() 
{ 
  // set a new terminate handler 
  set_terminate(my_Thandler); 
 
  try {  
    cout << "Inside try block\n"; 
    throw 100; // throw an error 
  } 
  catch (double i) { // won't catch an int exception 
    // ... 
  } 
 
  return 0; 
}

listing 26
#include <iostream> 
using namespace std; 
 
void divide(double a, double b); 
 
int main() 
{ 
  double i, j; 
 
  do { 
    cout << "Enter numerator (0 to stop): "; 
    cin >> i; 
    cout << "Enter denominator: "; 
    cin >> j; 
    divide(i, j); 
  } while(i != 0); 
 
  return 0; 
} 
 
void divide(double a, double b) 
{ 
  try { 
    if(!b) throw b; // check for divide-by-zero    
    cout << "Result: " << a/b << endl; 
  } 
  catch (double b) { 
    cout << "Can't divide by zero.\n"; 
  } 
}

listing 27
// An example that uses typeid. 
#include <iostream> 
#include <typeinfo> 
using namespace std; 
 
class BaseClass { 
  int a, b; 
  virtual void f() {}; // make BaseClass polymorphic 
}; 
 
class Derived1: public BaseClass { 
  int i, j; 
}; 
 
class Derived2: public BaseClass { 
  int k; 
}; 
 
int main() 
{ 
  int i; 
  BaseClass *p, baseob; 
  Derived1 ob1; 
  Derived2 ob2; 
 
  // First, display type name of a built in type. 
  cout << "Typeid of i is "; 
  cout << typeid(i).name() << endl; 
   
  // Demonstrate typeid with polymorphic types. 
  p = &baseob; 
  cout << "p is pointing to an object of type "; 
  cout << typeid(*p).name() << endl; 
 
  p = &ob1; 
  cout << "p is pointing to an object of type "; 
  cout << typeid(*p).name() << endl; 
 
  p = &ob2; 
  cout << "p is pointing to an object of type "; 
  cout << typeid(*p).name() << endl; 
 
  return 0; 
}

listing 28
#include <iostream> 
using namespace std; 
 
#define NUM_EMPLOYEES 4 
 
class employee { 
public: 
  employee() { cout << "Constructing employee\n"; } 
  virtual void print() = 0; 
}; 
 
class programmer : public employee { 
public: 
  programmer() { cout << "Constructing programmer\n"; } 
  void print() { cout << "Printing programmer object\n"; } 
}; 
 
class salesperson : public employee { 
public: 
  salesperson() { cout << "Constructing salesperson\n"; } 
  void print() { cout << "Printing salesperson object\n"; } 
}; 
 
class executive : public employee { 
public: 
  executive() { cout << "Constructing executive\n"; } 
  void print() { cout << "Printing executive object\n"; } 
}; 
 
int main() { 
  programmer prog1, prog2; 
  executive ex; 
  salesperson sp; 
 
  // Initialize the array of employees 
  employee *e[NUM_EMPLOYEES]; 
  e[0] = &prog1; 
  e[1] = &sp; 
  e[2] = &ex; 
  e[3] = &prog2; 
 
  // See which ones are programmers. 
  for(int i = 0; i < NUM_EMPLOYEES; i++) { 
    programmer *pp = dynamic_cast<programmer*>(e[i]); 
    if(pp) { 
      cout << "Is a programmer\n"; 
      pp->print(); 
    } 
    else { 
      cout << "Not a programmer\n"; 
    } 
  } 
}

listing 29
// An example that uses reinterpret_cast. 
#include <iostream> 
using namespace std; 
 
int main() 
{ 
  int i; 
  char *p = "This is a string"; 
 
  i = reinterpret_cast<int> (p); // cast pointer to integer 
 
  cout << i; 
 
  return 0; 
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产999大香线蕉| 日韩欧美国产一区二区三区| 精品一区二区三区视频在线观看| 一区二区三区成人在线视频| 亚洲精品写真福利| 亚洲欧美精品午睡沙发| 亚洲欧美一区二区久久| 一区二区三区在线视频观看 | 亚洲精品国产a久久久久久 | 亚洲狠狠爱一区二区三区| 自拍偷在线精品自拍偷无码专区| 国产日韩精品一区| 亚洲欧洲性图库| 亚洲国产综合人成综合网站| 亚洲大片一区二区三区| 日韩中文字幕区一区有砖一区| 婷婷成人综合网| 美女看a上一区| 国产福利视频一区二区三区| 成人美女视频在线看| 91免费看`日韩一区二区| 91精彩视频在线| 欧美丰满嫩嫩电影| 国产亲近乱来精品视频| 亚洲精品乱码久久久久久久久| 亚洲午夜一二三区视频| 久久成人综合网| av一区二区久久| 欧美一级淫片007| 中文av一区特黄| 亚洲h精品动漫在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 成人妖精视频yjsp地址| 欧美日韩一级黄| 中文字幕免费不卡在线| 日日夜夜精品视频天天综合网| 国产剧情一区二区| 欧美亚洲图片小说| 中文av一区二区| 欧美aⅴ一区二区三区视频| 成人免费黄色大片| 91精品国产入口| 一区二区三区 在线观看视频| 玖玖九九国产精品| 欧美日韩黄色影视| 亚洲人被黑人高潮完整版| 久久av中文字幕片| 精品视频一区 二区 三区| 久久人人爽爽爽人久久久| 亚洲国产成人高清精品| 成人激情免费视频| 久久天堂av综合合色蜜桃网| 亚洲成人精品一区| 91麻豆精品视频| 久久精品这里都是精品| 秋霞影院一区二区| 欧美日韩午夜在线视频| 一区二区三区不卡在线观看| 成人天堂资源www在线| 欧美大白屁股肥臀xxxxxx| 亚洲一区二区三区四区五区中文 | 麻豆国产精品官网| 91成人在线精品| 综合网在线视频| 成人国产免费视频| 久久久久久久久一| 国内精品久久久久影院色| 欧美一区二区三区四区在线观看| 亚洲综合成人在线视频| 色婷婷久久99综合精品jk白丝| 欧美国产成人在线| 国产成人精品亚洲777人妖| 精品国产三级电影在线观看| 人人爽香蕉精品| 精品剧情在线观看| 国产精品一区一区| 国产日韩欧美高清在线| 成人听书哪个软件好| 国产精品乱人伦中文| 国产iv一区二区三区| 欧美激情在线免费观看| 成人少妇影院yyyy| 亚洲人成人一区二区在线观看| 色综合亚洲欧洲| 亚洲国产成人精品视频| 91精品久久久久久久99蜜桃| 视频一区二区不卡| 欧美va亚洲va香蕉在线| 国产一区不卡视频| 国产精品久久久久久久久快鸭| 成人av网址在线观看| 一区二区中文视频| 欧美日本一区二区三区四区| 免费观看日韩av| 久久久美女艺术照精彩视频福利播放| 国产剧情在线观看一区二区| 国产精品久久99| 欧美性xxxxxxxx| 久久99精品久久只有精品| 国产女人18水真多18精品一级做 | 无码av免费一区二区三区试看| 欧美日韩成人激情| 国产在线视频一区二区| 国产精品乱人伦| 欧美美女网站色| 国产专区综合网| 亚洲欧美一区二区三区国产精品 | 国产精品资源在线观看| 亚洲欧洲日韩av| 欧美一级高清片| 91丨九色丨蝌蚪丨老版| 奇米精品一区二区三区在线观看 | 成人动漫在线一区| 亚洲国产精品久久艾草纯爱| 精品国精品国产| 欧美日韩亚洲综合| 丁香激情综合国产| 久久精品噜噜噜成人av农村| 综合欧美亚洲日本| 久久网站热最新地址| 欧美日韩国产一区二区三区地区| 国产成人激情av| 奇米色777欧美一区二区| 亚洲欧美日韩中文字幕一区二区三区| 日韩精品一区二区三区老鸭窝| 99久久综合国产精品| 国产一区视频网站| 亚洲成人久久影院| 亚洲综合在线视频| 专区另类欧美日韩| 国产日韩欧美精品在线| 欧美大片在线观看| 日韩一区二区三区在线观看| 欧美专区亚洲专区| 91在线观看下载| 丰满亚洲少妇av| 粉嫩一区二区三区在线看| 美女mm1313爽爽久久久蜜臀| 亚瑟在线精品视频| 亚洲福利电影网| 五月婷婷久久丁香| 亚洲国产人成综合网站| 亚洲卡通欧美制服中文| 国产精品高清亚洲| 中文字幕免费一区| 国产精品久久久久久久裸模| 精品国产1区二区| 欧美tickling挠脚心丨vk| 欧美一级国产精品| 精品乱人伦一区二区三区| 日韩欧美精品在线视频| 欧美成人一区二区| 久久久国产精品不卡| 国产日产欧美精品一区二区三区| 久久综合99re88久久爱| 久久精品一区二区三区av| 久久久综合精品| 国产精品久久久久久久久免费桃花| 久久在线免费观看| 亚洲国产高清不卡| 日韩伦理电影网| 亚洲狠狠爱一区二区三区| 亚洲777理论| 老司机精品视频线观看86| 韩国av一区二区三区四区| 国产成人av自拍| 色婷婷久久综合| 欧美一区二区在线不卡| 精品人伦一区二区色婷婷| 欧美国产一区二区| 亚洲精品国产精品乱码不99| 亚洲国产精品久久久男人的天堂| 日本伊人精品一区二区三区观看方式| 美女视频黄久久| 99re视频精品| 日韩午夜中文字幕| 亚洲视频一区二区在线| 日韩电影在线一区二区三区| 国内久久婷婷综合| 日本韩国欧美在线| 欧美videossexotv100| 国产精品视频免费看| 亚洲一区影音先锋| 国产乱子伦一区二区三区国色天香| 国产成人av电影| 欧美撒尿777hd撒尿| 日韩美女一区二区三区四区| 中文字幕一区二区三区精华液| 亚洲一区二区三区影院| 国产传媒一区在线| 欧美日韩国产片| 欧美国产1区2区| 美女高潮久久久| 欧美在线短视频| 国产日韩精品一区二区三区| 婷婷久久综合九色综合绿巨人| 高清久久久久久| 精品国产一区二区三区四区四| 亚洲三级视频在线观看| 久久97超碰色|