期中复习\t\r ?
1. 复习方法\t\r ?
理论课考试复习:讲义和习题中的内容,概念的英文表达方法(下面的概念中英对照),熟练概念在C++中的应用。\t\r ?\t\r ?
试验课考试复习:上机作业,课后作业,和其编程习题。\t\r ?\t\r ?
2. 理论课考试题型:\t\r ?
\t\r ?
单项选择题\t\r ?
Which\t\r ?of\t\r ?the\t\r ?following\t\r ?is\t\r ?true\t\r ?about\t\r ?a\t\r ?constructor?\t\r ?A)\t\r ?it\t\r ?has\t\r ?a\t\r ?return\t\r ?type\t\r ?
B)\t\r ?it\t\r ?cannot\t\r ?have\t\r ?any\t\r ?parameter\t\r ?
C)\t\r ?it\t\r ?is\t\r ?the\t\r ?first\t\r ?function\t\r ?for\t\r ?an\t\r ?object\t\r ?(the\t\r ?answer)\t\r ?D)\t\r ?it\t\r ?can\t\r ?be\t\r ?called\t\r ?any\t\r ?number\t\r ?of\t\r ?times\t\r ?for\t\r ?an\t\r ?object\t\r ?\t\r ?概念题\t\r ?polymorphism\t\r ?
answer:\t\r ?objects\t\r ?of\t\r ?different\t\r ?classes\t\r ?are\t\r ?handled\t\r ?via\t\r ?the\t\r ?same\t\r ?interface.\t\r ?\t\r ?
输出分析题\t\r ?
1 class A 2 { 3 public:
4 A(int id) { cout << \ << id << endl; } 5 }; 6
7 class B : public A 8 { 9 A a; 10 public:
11 B(int id) : a(id + 1), A(id + 2) { 12 cout << \ << id << endl; 13 } 14 }; 15
16 int main() { B b(100); }
answer:\t\r ?A(int)\t\r ?102\t\r ?A(int)\t\r ?101\t\r ?B(int)\t\r ?100\t\r ?\t\r ?改错题\t\r ?
1 class A 2 { 3 public:
4 A(int id) { cout << \ << id << endl; } 5 }; 6
7 class B : public A 8 {
9 A a(101); 10 public:
11 B(int id) { 12 A(id + 2);
13 cout << \ << id << endl; 14 }
15 }; 16
17 int main() { B b; }
\t\r ?
程序设计题\t\r ?
Design\t\r ?a\t\r ?class\t\r ?String\t\r ?that\t\r ?has\t\r ?the\t\r ?following\t\r ?member\t\r ?variables:\t\r ?
char * array;
,\t\r ?and\t\r ?the\t\r ?following\t\r ?member\t\r ?functions:\t\r ?
String(const String &);
String & operator = (const String &); ~String();
String(const char text[]);
String & operator += (const String &); String operator + (const String &) const; int size() const;
\t\r ?
3. 概念中英对照\t\r ?
\t\r ?
compound\t\r ?data\t\r ?type\t\r ?复合数据类型\t\r ?abstract\t\r ?data\t\r ?type\t\r ?抽象数据类型\t\r ?class\t\r ?类\t\r ?
object:\t\r ?variable\t\r ?of\t\r ?a\t\r ?class\t\r ?对象:类的变量\t\r ?member\t\r ?variable\t\r ?
成员变量\t\r ?member\t\r ?function\t\r ?成员函数\t\r ?
object\t\r ?function:\t\r ?an\t\r ?object\t\r ?function\t\r ?must\t\r ?be\t\r ?called\t\r ?with\t\r ?an\t\r ?object.\t\r ?
对象函数:一个对象函数必须由一个对象调用。\t\r ?
the\t\r ?invisible\t\r ?parameter\t\r ?of\t\r ?a\t\r ?object\t\r ?function:\t\r ?the\t\r ?object\t\r ?with\t\r ?which\t\r ?the\t\r ?object\t\r ?function\t\r ?is\t\r ?called.\t\r ?
对象函数的隐形对象参数:调用对象函数的对象。\t\r ?constructor:\t\r ?they\t\r ?have\t\r ?no\t\r ?return\t\r ?type,\t\r ?their\t\r ?names\t\r ?are\t\r ?the\t\r ?same\t\r ?as\t\r ?their\t\r ?class\t\r ?names,\t\r ?they\t\r ?are\t\r ?called\t\r ?automatically\t\r ?to\t\r ?initialize\t\r ?objects,\t\r ?exactly\t\r ?one\t\r ?constructor\t\r ?cannot\t\r ?be\t\r ?called\t\r ?for\t\r ?each\t\r ?object.\t\r ?The\t\r ?first\t\r ?function\t\r ?each\t\r ?object\t\r ?calls\t\r ?must\t\r ?be\t\r ?one\t\r ?of\t\r ?its\t\r ?constructors.\t\r ?
构造函数:没有返回值,名字必须与类的名字相同,会被自动调用以初始化对象,每个对象只会调用一个构造函数,是每个对象调用的第一个函数。\t\r ?
destructor:\t\r ?it\t\r ?does\t\r ?not\t\r ?have\t\r ?a\t\r ?return\t\r ?type,\t\r ?it\t\r ?is\t\r ?called\t\r ?automatically,\t\r ?it\t\r ?cannot\t\r ?be\t\r ?called\t\r ?more\t\r ?than\t\r ?once.\t\r ?The\t\r ?last\t\r ?function\t\r ?that\t\r ?each\t\r ?object\t\r ?calls\t\r ?must\t\r ?be\t\r ?its\t\r ?destructor.\t\r ?释构函数:没有返回值,会被自动调用,每个对象只会调用一次,是每个对象调用的最后一个函数。\t\r ?
operator\t\r ?function:\t\r ?if\t\r ?one\t\r ?of\t\r ?the\t\r ?operands\t\r ?is\t\r ?an\t\r ?object,\t\r ?the\t\r ?action\t\r ?of\t\r ?an\t\r ?operator\t\r ?can\t\r ?be\t\r ?defined\t\r ?in\t\r ?a\t\r ?function.\t\r ?each\t\r ?binary\t\r ?operator\t\r ?function\t\r ?has\t\r ?two\t\r ?parameters,\t\r ?and\t\r ?each\t\r ?unary\t\r ?operator\t\r ?function\t\r ?has\t\r ?one\t\r ?parameter.\t\r ?If\t\r ?it\t\r ?is\t\r ?an\t\r ?object\t\r ?function,\t\r ?each\t\r ?binary\t\r ?operator\t\r ?function\t\r ?has\t\r ?one\t\r ?parameter,\t\r ?and\t\r ?each\t\r ?unary\t\r ?operator\t\r ?has\t\r ?one\t\r ?parameter.\t\r ?\t\r ?
操作符函数:如果其中一个操作数是对象,操作符的动作可以被定义为一个函数。二元操作符函数有两个参数,一元操作符函数有一个参数。如果是对象函数,二元操作符函数有一个参数,一元操作符函数没有参数。\t\r ?operator\t\r ?overload:\t\r ?define\t\r ?a\t\r ?operator\t\r ?function.\t\r ?操作符重载:定义一个操作符函数。\t\r ?\t\r ?
encapsulation:\t\r ?hide\t\r ?data\t\r ?that\t\r ?is\t\r ?vulnerable\t\r ?to\t\r ?errors,\t\r ?and\t\r ?provide\t\r ?functions\t\r ?that\t\r ?manipulate\t\r ?the\t\r ?data\t\r ?easily\t\r ?and\t\r ?safely.\t\r ?封装:隐藏易出错的数据,并提供简便和安全的函数来操作它们。\t\r ?
constant\t\r ?object:\t\r ?a\t\r ?constant\t\r ?object\t\r ?cannot\t\r ?be\t\r ?assigned\t\r ?a\t\r ?new\t\r ?value;\t\r ?its\t\r ?member\t\r ?variables\t\r ?cannot\t\r ?be\t\r ?assigned\t\r ?new\t\r ?values\t\r ?too;\t\r ?its\t\r ?non--‐constant\t\r ?object\t\r ?functions\t\r ?cannot\t\r ?be\t\r ?called;\t\r ?it\t\r ?cannot\t\r ?be\t\r ?passed\t\r ?to\t\r ?a\t\r ?reference\t\r ?of\t\r ?a\t\r ?variable.\t\r ?
常量对象:常量对象不可以被赋值,它的成员变量也不可
C++程序设计 midterm-review



