- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
03 C++ Basics Ⅰ Usage of Pointer to functions Simply code Like “hook” Homework Design a program which can implement the following functions: Get the student information data, which includes name, ID, age and so on, from the standard input stream; Output these information into the standard output stream according to the specific student’s id. * vector are recommended as the data type for the container of student information. * 课时数:8学时 Exception Specifications Throwing or catching an exception affects the way a function relates to other functions. It can therefore be worthwhile to specify the set of exceptions that might be thrown as part of the function declaration. For example: void f(int a) throw (x2, x3); The most important advantage is that the function declaration belongs to an interface that is visible to its callers. Exception Specifications A function declared without an exception specification is assumed to throw every exception. For example: int f(); // can throw any exception A function that will throw no exceptions can be declared with an empty list: int g() throw(); // no exception thrown Questions??? To find the errors that may be occurred. int* alloc_and_init(char* file_name){ ifstream infile(file_name); int elem_cnt; infileelem_cnt; int* pi = allocate_array(elem_cnt); int elem; int index=0; while(infileelem) pi[index++] = elem; sort_array(pi, elem_cnt); register_data(pi); return pi; } Functions A function can be thought of as a programmer-designed operation. Each function represent/implement computations/calculations and (usually) yield a result. Why to use functions? Defining a function Argument passing The return Statement Default Argument Inline function Overloading Function Pointer to functions Top-Down Design Browser Program Top-Down Design Top-Down Design User Interface Thread Pool Cache Manager Update Manager Connection Manager Browser Top-Down Design UI tabs UI LF UI Menu Thre
文档评论(0)