c大學基礎教程第五版答案
㈠ 求《C++大學教程》(國外Harvey M.Deitel的第五版電子工業出版)社課後習題答案,我郵箱:[email protected]
laile
㈡ 想要學習C++ 有一些C基礎 不知道《C++大學基礎教程》第五版 適合不適合入門 請大蝦指導
1.把C++當成一門新的語言學習(和C沒啥關系!真的。);
2.看《Thinking In C++》,不要看《C++變成死相》;
3.看《The C++ Programming Language》和《Inside The C++ Object Model》,不要因為他們很難而我們自己是初學者所以就不看;
4.不要被VC、BCB、BC、MC、TC等詞彙所迷惑——他們都是集成開發環境,而我們要學的是一門語言;
5.不要放過任何一個看上去很簡單的小編程問題——他們往往並不那麼簡單,或者可以引伸出很多知識點;
6.會用Visual C++,並不說明你會C++;
7.學class並不難,template、STL、generic programming也不過如此——難的是長期堅持實踐和不遺餘力的博覽群書;
8.如果不是天才的話,想學編程就不要想玩游戲——你以為你做到了,其實你的C++水平並沒有和你通關的能力一起變高——其實可以時刻記住:學C++是為了編游戲的;
9.看Visual C++的書,是學不了C++語言的;
10.浮躁的人容易說:XX語言不行了,應該學YY;——是你自己不行了吧!?
11.浮躁的人容易問:我到底該學什麼;——別問,學就對了;
12.浮躁的人容易問:XX有錢途嗎;——建議你去搶銀行;
13.浮躁的人容易說:我要中文版!我英文不行!——不行?學呀!
14.浮躁的人容易問:XX和YY哪個好;——告訴你吧,都好——只要你學就行;
15.浮躁的人分兩種:a)只觀望而不學的人;b)只學而不堅持的人;
16.把時髦的技術掛在嘴邊,還不如把過時的技術記在心裡;
17.C++不僅僅是支持面向對象的程序設計語言;
18.學習編程最好的方法之一就是閱讀源代碼;
19.在任何時刻都不要認為自己手中的書已經足夠了;
20.請閱讀《The Standard C++ Bible》(中文版:標准C++寶典),掌握C++標准;
21.看得懂的書,請仔細看;看不懂的書,請硬著頭皮看;
22.別指望看第一遍書就能記住和掌握什麼——請看第二遍、第三遍;
23.請看《Effective C++》和《More Effective C++》以及《Exceptional C++》;
24.不要停留在集成開發環境的搖籃上,要學會控制集成開發環境,還要學會用命令行方式處理程序;
25.和別人一起討論有意義的C++知識點,而不是爭吵XX行不行或者YY與ZZ哪個好;
26.請看《程序設計實踐》,並嚴格的按照其要求去做;
27.不要因為C和C++中有一些語法和關鍵字看上去相同,就認為它們的意義和作用完全一樣;
28.C++絕不是所謂的C的「擴充」——如果C++一開始就起名叫Z語言,你一定不會把C和Z語言聯系得那麼緊密;
29.請不要認為學過XX語言再改學C++會有什麼問題——你只不過又在學一門全新的語言而已;
30.讀完了《Inside The C++ Object Model》以後再來認定自己是不是已經學會了C++;
31.學習編程的秘訣是:編程,編程,再編程;
32.請留意下列書籍:《C++面向對象高效編程(C++ Effective Object-Oriented Software Construction)》《面向對象軟體構造(Object-Oriented Software Construction)》《設計模式(Design Patterns)》《The Art of Computer Programming》;
33.記住:面向對象技術不只是C++專有的;
34.請把書上的程序例子親手輸入到電腦上實踐,即使配套光碟中有源代碼;
35.把在書中看到的有意義的例子擴充;
36.請重視C++中的異常處理技術,並將其切實的運用到自己的程序中;
37.經常回顧自己以前寫過的程序,並嘗試重寫,把自己學到的新知識運用進去;
38.不要漏掉書中任何一個練習題——請全部做完並記錄下解題思路;
39.C++語言和C++的集成開發環境要同時學習和掌握;
40.既然決定了學C++,就請堅持學下去,因為學習程序設計語言的目的是掌握程序設計技術,而程序設計技術是跨語言的;
41.就讓C++語言的各種平台和開發環境去激烈的競爭吧,我們要以學習C++語言本身為主;
42.當你寫C++程序寫到一半卻發現自己用的方法很拙劣時,請不要馬上停手;請盡快將餘下的部分粗略的完成以保證這個設計的完整性,然後分析自己的錯誤並重新設計和編寫(參見43);
43.別心急,設計C++的class確實不容易;自己程序中的class和自己的class設計水平是在不斷的編程實踐中完善和發展的;
44.決不要因為程序「很小」就不遵循某些你不熟練的規則——好習慣是培養出來的,而不是一次記住的;
45.每學到一個C++難點的時候,嘗試著對別人講解這個知識點並讓他理解——你能講清楚才說明你真的理解了;
46.記錄下在和別人交流時發現的自己忽視或不理解的知識點;
47.請不斷的對自己寫的程序提出更高的要求,哪怕你的程序版本號會變成Version 100.XX;
48.保存好你寫過的所有的程序——那是你最好的積累之一;
49.請不要做浮躁的人;
50.請熱愛C++!
---------------------------------------------以上是別人的建議,作以補充------------------------------------
第一本:《Thinking In C++》 轉變到C++的模式
然後:《The C++ Programming Language》 C++之父的經典之作,無可替代
《Inside The C++ Object Model》 需要一定的基礎,先過一遍,對程序有一定理解了需要再一點點的慢慢看。
看 《unix環境高級編程》《unix網路編程 卷一》 不論你是windows平台還是unix平台,這兩本都是很有益處的,不過價格不菲,實在不捨得的話,建議看第二本網路編程
期間可以看一些小書,關於C++的 《effective C++》 《more effective c++》 等等亂七八糟的也無所謂了。 期間會對C++有深入理解。可以選自己覺得不錯的書一遍遍的看。
㈢ 《c大學教程》第五版 習題答案 為提供者追加200分
第四版的答案:
http://www.rayfile.com/zh-cn/files/c4d7ca40-8d1e-11dd-9634-0019d11a795f/
㈣ 誰有山東大學出版社《量子力學基礎教程》陳鄂生第五版的答案啊實在不行其他版也行啊。
國內但言量子力學教材,則稱曾謹言、錢伯初、周世勛,很少有人在意陳鄂生先生這本小藍書的.我卻覺得這本書寫的流暢疏簡,脈絡清晰,十分適合做量子力學的入門教材.曾謹言先生的書,內容龐雜,講授方法,說真的,但求全面而不在意是否邏輯清晰.有時候還會有錯誤,尤其是在第二卷.如果在有了一定基礎之後,拿來當工具書,還是可以的.初學就看這個,很容易被裡面眾多公式、方程嚇到.陳先生的這本書,在量子力學五大基本假設、算符方法、角動量理論、表象變換理論、自旋引入、微繞理論以及散射理論方面的講解都很清簡,在不忽略物理的情況下,盡量把數學做到最少.有時候過分的加入數學,反而會使物理在公式方程的籠罩之下變得模糊.陳先生的書,用簡單的例子,就可以把量子力學的基本原理、基本方法講的很清楚.本書有數量適中的習題,大都是出自於這些年來的考研題目,很經典.本書還有一本配套的習題解答,全是歷年各高校、研究所考研題目的匯編集解,應該是考研不可缺少的參考書.如果能夠把那本參考書中的題目,都能親手算一遍的話,就會發現原來理解不對、或者沒有理解的地方慢慢的便理解了.不管你學量子力學的時候用的是誰的教材,這本書配套的習題集,還是非常值得通做一遍的,就算不是為了考研,而是為了理解量子力學,也是值得的.
㈤ c++程序設計基礎教程課後答案(清華大學出版社鄭莉 董淵著)
第 一 章 概述
1-1 簡述計算機程序設計語言的發展歷程。
解:
迄今為止計算機程序設計語言的發展經歷了機器語言、匯編語言、高級語言等階段,C++語言是一種面向對象的編程語言,也屬於高級語言。
1-2 面向對象的編程語言有哪些特點?
解:
面向對象的編程語言與以往各種編程語言有根本的不同,它設計的出發點就是為了能更直接的描述客觀世界中存在的事物以及它們之間的關系。面向對象的編程語言將客觀事物看作具有屬性和行為的對象,通過抽象找出同一類對象的共同屬性(靜態特徵)和行為(動態特徵),形成類。通過類的繼承與多態可以很方便地實現代碼重用,大大縮短了軟體開發周期,並使得軟體風格統一。因此,面向對象的編程語言使程序能夠比較直接地反問題域的本來面目,軟體開發人員能夠利用人類認識事物所採用的一般思維方法來進行軟體開發。C++語言是目前應用最廣的面向對象的編程語言。
1-3 什麼是結構化程序設計方法?這種方法有哪些優點和缺點?
解:
結構化程序設計的思路是:自頂向下、逐步求精;其程序結構是按功能劃分為若干個基本模塊;各模塊之間的關系盡可能簡單,在功能上相對獨立;每一模塊內部均是由順序、選擇和循環三種基本結構組成;其模塊化實現的具體方法是使用子程序。結構化程序設計由於採用了模塊分解與功能抽象,自頂向下、分而治之的方法,從而有效地將一個較復雜的程序系統設計任務分解成許多易於控制和處理的子任務,便於開發和維護。
雖然結構化程序設計方法具有很多的優點,但它仍是一種面向過程的程序設計方法,它把數據和處理數據的過程分離為相互獨立的實體。當數據結構改變時,所有相關的處理過程都要進行相應的修改,每一種相對於老問題的新方法都要帶來額外的開銷,程序的可重用性差。
由於圖形用戶界面的應用,程序運行由順序運行演變為事件驅動,使得軟體使用起來越來越方便,但開發起來卻越來越困難,對這種軟體的功能很難用過程來描述和實現,使用面向過程的方法來開發和維護都將非常困難。
1-4 什麼是對象?什麼是面向對象方法?這種方法有哪些特點?
解:
從一般意義上講,對象是現實世界中一個實際存在的事物,它可以是有形的,也可以是無形的。對象是構成世界的一個獨立單位,它具有自己的靜態特徵和動態特徵。面向對象方法中的對象,是系統中用來描述客觀事物的一個實體,它是用來構成系統的一個基本單位,由一組屬性和一組行為構成。
面向對象的方法將數據及對數據的操作方法放在一起,作為一個相互依存、不可分離的整體--對象。對同類型對象抽象出其共性,形成類。類中的大多數數據,只能用本類的方法進行處理。類通過一個簡單的外部介面,與外界發生關系,對象與對象之間通過消息進行通訊。這樣,程序模塊間的關系更為簡單,程序模塊的獨立性、數據的安全性就有了良好的保障。通過實現繼承與多態性,還可以大大提高程序的可重用性,使得軟體的開發和維護都更為方便。
面向對象方法所強調的基本原則,就是直接面對客觀存在的事物來進行軟體開發,將人們在日常生活中習慣的思維方式和表達方式應用在軟體開發中,使軟體開發從過分專業化的方法、規則和技巧中回到客觀世界,回到人們通常的思維。
1-5 什麼叫做封裝?
解:
封裝是面向對象方法的一個重要原則,就是把對象的屬性和服務結合成一個獨立的系統單位,並盡可能隱蔽對象的內部細節。
1-6 面向對象的軟體工程包括哪些主要內容?
解:
面向對象的軟體工程是面向對象方法在軟體工程領域的全面應用,它包括面向對象的分析(OOA)、面向對象的設計(OOD)、面向對象的編程(OOP)、面向對象的測試(OOT)和面向對象的軟體維護(OOSM)等主要內容。
1-7 簡述計算機內部的信息可分為幾類?
解:
計算機內部的信息可以分成控制信息和數據信息二大類;控制信息可分為指令和控制字兩類;數據信息可分為數值信息和非數值信息兩類。
1-8 什麼叫二進制?使用二進制有何優點和缺點?
解:
二進制是基數為2,每位的權是以2 為底的冪的進制,遵循逢二進一原則,基本符號為0和1。採用二進制碼表示信息,有如下幾個優點:1.易於物理實現;2.二進制數運算簡單;3.機器可靠性高;4.通用性強。其缺點是它表示數的容量較小,表示同一個數,二進制較其他進制需要更多的位數。
1-9 請將以下十進制數值轉換為二進制和十六進制補碼:
(1)2 (2)9 (3)93
(4)-32 (5)65535 (6)-1
解:
(1) (2)10 = (10)2 = (2)16
(2) (9)10 = (1001)2 = (9)16
(3) (93)10 = (1011101)2 = (5D)16
(4) (-32)10 = (11100000)2 = (E0)16
(5) (65535)10 = (11111111 11111111)2 = (FFFF)16
(6) (-1)10 = (11111111 11111111)2 = (FFFF)16
1-10 請將以下數值轉換為十進制:
(1)(1010)2 (2)(10001111)2 (3)(01011111 11000011)2
(4)(7F)16 (5)(2D3E)16 (6)(F10E)16
解:
(1)(1010)2 = (10)10
(2)(10001111)2 = (143)10
(3)(01011111 11000011)2 = (24515)10
(4)(7F)16 = (127)10
(5)(2D3E)16 = (11582)10
(6)(F10E)16 = (61710)10
1-11 簡要比較原碼、反碼、補碼等幾種編碼方法。
解:
原碼:將符號位數字化為 0 或 1,數的絕對值與符號一起編碼,即所謂"符號——絕對值表示"的編碼。
正數的反碼和補碼與原碼表示相同。
負數的反碼與原碼有如下關系:
符號位相同(仍用1表示),其餘各位取反(0變1,1變0)。
補碼由該數反碼的最末位加1求得。
第 二 章 C++簡單程序設計
2-1 C++語言有那些主要特點和優點?
解:
C++語言的主要特點表現在兩個方面,一是全面兼容C,二是支持面向對象的方法。C++是一個更好的C,它保持了C的簡潔、高效、接近匯編語言、具有良好的可讀性和可移植性等特點,對C的類型系統進行了改革和擴充,因此C++比C更安全,C++的編譯系統能檢查出更多的類型錯誤。 C++語言最重要的特點是支持面向對象。
2-2 下列標識符哪些是合法的?
Program, -page, _lock, test2, 3in1, @mail, A_B_C_D
解:
Program, _lock, test2, A_B_C_D是合法的標識符,其它的不是。
2-3 例2.1中每條語句的作用是什麼?
#include <iostream.h>
void main(void)
{
cout<<"Hello!\n";
cout<<"Welcome to c++!\n";
}
解:
#include <iostream.h> //指示編譯器將文件iostream.h中的代碼
//嵌入到該程序中該指令所在的地方
void main() //主函數名,void 表示函數沒有返回值
{ //函數體標志
cout<<"Hello!\n"; //輸出字元串Hello!到標准輸出設備(顯示器)上。
cout<<"Welcome to c++!\n"; //輸出字元串Welcome to c++!
}
在屏幕輸出如下:
Hello!
Welcome to c++!
2-4 使用關鍵字const而不是#define語句的好處有哪些?
解:
const定義的常量是有類型的,所以在使用它們時編譯器可以查錯;而且,這些變數在調試時仍然是可見的。
2-5 請寫出C++語句聲明一個常量PI,值為3.1416;再聲明一個浮點型變數a,把PI的值賦給a。
解:
const float PI = 3.1416;
float a = PI;
2-6 在下面的枚舉類型中,Blue的值是多少?
enum COLOR ;
解:
Blue = 102
2-7 注釋有什麼作用?C++中有哪幾種注釋的方法?他們之間有什麼區別?
解:
注釋在程序中的作用是對程序進行註解和說明,以便於閱讀。編譯系統在對源程序進行編譯時不理會注釋部分,因此注釋對於程序的功能實現不起任何作用。而且由於編譯時忽略注釋部分,所以注釋內容不會增加最終產生的可執行程序的大小。適當地使用注釋,能夠提高程序的可讀性。在C++中,有兩種給出注釋的方法:一種是延用C語言方法,使用"/*"和"*/"括起注釋文字。另一種方法是使用"//",從"//"開始,直到它所在行的行尾,所有字元都被作為注釋處理。
2-8 什麼叫做表達式?x = 5 + 7是一個表達式嗎?它的值是多少?
解:
任何一個用於計算值的公式都可稱為表達式。x = 5 + 7是一個表達式,它的值為12。
2-9 下列表達式的值是多少?
1. 201 / 4
2. 201 % 4
3. 201 / 4.0
解:
1. 50
2. 1
3. 50.25
2-10 執行完下列語句後,a、b、c三個變數的值為多少?
a = 30;
b = a++;
c = ++a;
解:
a:32 ; b:30 ; c:32;
2-11 在一個for循環中,可以初始化多個變數嗎?如何實現?
解:
在for循環設置條件的第一個";"前,用,分隔不同的賦值表達式。
例如:
for (x = 0, y = 10; x < 100; x++, y++)
2-12 執行完下列語句後,n的值為多少?
int n;
for (n = 0; n < 100; n++)
㈥ 您好,《c++大學基礎教程第五版》89頁建立invoice類的題目做錯,自學中,求助!
主程序中 main()
中有全形的,和;
應為:
int main ()
{
Invoice Invoice1( "89757", "huawei honor",1000, 1999 );
Invoice1.getInvoiceAmount();
return 0; /**/
}
㈦ C++大學教程(第5版)課後答案
http://www.gougou.com/search?search=c%2B%2B%E8%AF%BE%E5%90%8E%E7%AD%94%E6%A1%88&restype=-1&id=10000001&ty=0&pattern=0
自己下載吧,有你需要的。
㈧ 求《C++大學基礎教程》 第五版 deitel 著 電子工業出版社 課後答案 是基礎教程!!!
C 大學基礎教程 課後答案DEITEL版 3.11 GradeBook類定義 include ltstringgt // program uses C standard string class using std::string class GradeBook public: // constructor initializes course name and instructor name GradeBook string string void setCourseName string // function to set the course name string getCourseName // function to retrieve the course name void setInstructorName string // function to set instructor name string getInstructorName // function to retrieve instructor name void displayMessage // display welcome message and instructor name private: string courseName // course name for this GradeBook string instructorName // instructor name for this GradeBook // end class GradeBook 類成員函數 include ltiostreamgt using std::cout using std::endl include quotGradeBook.hquot // constructor initializes courseName and instructorName // with strings supplied as arguments GradeBook::GradeBook string course string instructor setCourseName course // initializes courseName setInstructorName instructor // initialiZes instructorName // end GradeBook constructor // function to set the course name void GradeBook::setCourseName string name courseName name // store the course name // end function setCourseName // function to retrieve the course name string GradeBook::getCourseName return courseName // end function getCourseName // function to set the instructor name void GradeBook::setInstructorName string name instructorName name // store the instructor name // end function setInstructorName // function to retrieve the instructor name string GradeBook::getInstructorName return instructorName // end function getInstructorName // display a welcome message and the instructors name void GradeBook::displayMessage // display a welcome message containing the course name cout ltlt quotWelcome to the grade book fornquot ltlt getCourseName ltlt quotquot ltlt endl // display the instructors name cout ltlt quotThis course is presented by: quot ltlt getInstructorName ltlt endl // end function displayMessage 測試文件 include ltiostreamgt using std::cout using std::endl // include definition of class GradeBook from GradeBook.h include quotGradeBook.hquot // function main begins program execution int main // create a GradeBook object pass a course name and instructor name GradeBook gradeBook quotCS101 Introction to C Programmingquot quotProfessor Smithquot // display initial value of instructorName of GradeBook object cout ltlt quotgradeBook instructor name is: quot ltlt gradeBook.getInstructorName ltlt quotnnquot // modify the instructorName using set function gradeBook.setInstructorName quotAssistant Professor Batesquot // display new value of instructorName cout ltlt quotnew gradeBook instructor name is: quot ltlt gradeBook.getInstructorName ltlt quotnnquot // display welcome message and instructors name gradeBook.displayMessage return 0 // indicate successful termination // end main 3.12 類定義 class Account public: Account int // constructor initializes balance void credit int // add an amount to the account balance void debit int // subtract an amount from the account balance int getBalance // return the account balance private: int balance // data member that stores the balance // end class Account 類成員函數 include ltiostreamgt using std::cout using std::endl include quotAccount.hquot // include definition of class Account // Account constructor initializes data member balance Account::Account int initialBalance balance 0 // assume that the balance begins at 0 // if initialBalance is greater than 0 set this value as the // balance of the Account otherwise balance remains 0 if initialBalance gt 0 balance initialBalance // if initialBalance is negative print error message if initialBalance lt 0 cout ltlt quotError: Initial balance cannot be negative.nquot ltlt endl // end Account constructor // credit add an amount to the account balance void Account::credit int amount balance balance amount // add amount to balance // end function credit // debit subtract an amount from the account balance void Account::debit int amount if amount gt balance // debit amount exceeds balance cout ltlt quotDebit amount exceeded account balance.nquot ltlt endl if amount lt balance // debit amount does not exceed balance balance balance - amount // end function debit // return the account balance int Account::getBalance return balance // gives the value of balance to the calling function // end function getBalance 測試函數 include ltiostreamgt using std::cout using std::cin using std::endl // include definition of class Account from Account.h include quotAccount.hquot // function main begins program execution int main Account account1 50 // create Account object Account account2 25 // create Account object // display initial balance of each object cout ltlt quotaccount1 balance: quot ltlt account1.getBalance ltlt endl cout ltlt quotaccount2 balance: quot ltlt account2.getBalance ltlt endl int withdrawalAmount // stores withdrawal amount read from user cout ltlt quotnEnter withdrawal amount for account1: quot // prompt cin gtgt withdrawalAmount // obtain user input cout ltlt quotnattempting to subtract quot ltlt withdrawalAmount ltlt quot from account1 balancennquot account1.debit withdrawalAmount // try to subtract from account1 // display balances cout ltlt quotaccount1 balance: quot ltlt account1.getBalance ltlt endl cout ltlt quotaccount2 balance: quot ltlt account2.getBalance ltlt endl cout ltlt quotnEnter withdrawal amount for account2: quot // prompt cin gtgt withdrawalAmount // obtain user input cout ltlt quotnattempting to subtract quot ltlt withdrawalAmount ltlt quot from account2 balancennquot account2.debit withdrawalAmount // try to subtract from account2 // display balances cout ltlt quotaccount1 balance: quot ltlt account1.getBalance ltlt endl cout ltlt quotaccount2 balance: quot ltlt account2.getBalance ltlt endl return 0 // indicate successful termination // end main 3.13 類定義 include ltstringgt // program uses C standard string class using std::string // Invoice class definition class Invoice public: // constructor initializes the four data members Invoice string string int int // set and get functions for the four data members void setPartNumber string // part number string getPartNumber void setPartDescription string // part description string getPartDescription void setQuantity int // quantity int getQuantity void setPricePerItem int // price per item int getPricePerItem // calculates invoice amount by multiplying quantity x price per item int getInvoiceAmount private: string partNumber // the number of the part being sold string partDescription // description of the part being sold int quantity // how many of the items are being sold int pricePerItem // price per item // end class Invoice 類成員函數 include ltiostreamgt using std::cout using std::endl // include definition of class Invoice from Invoice.h include quotInvoice.hquot // Invoice constructor initializes the classs four data members Invoice::Invoice string number string description int count int price setPartNumber number // store partNumber setPartDescription description // store partDescription setQuantity count // validate and store quantity setPricePerItem price // validate and store pricePerItem // end Invoice constructor // set part number void Invoice::setPartNumber string number partNumber number // no validation needed // end function setPartNumber // get part number string Invoice::getPartNumber return partNumber // end function getPartNumber // set part description void Invoice::setPartDescription string description partDescription description // no validation needed // end function setPartDescription // get part description string Invoice::getPartDescription return partDescription // end function getPartDescription // set quantity if not positive set to 0 void Invoice::setQuantity int count if count gt 0 // if quantity is positive quantity count // set quantity to count if count lt 0 // if quantity is not positive quantity 0 // set quantity to 0 cout ltlt quotnquantity cannot be negative. quantity set to 0.nquot // end if // end function setQuantity // get quantity int Invoice::getQuantity return quantity // end function getQuantity // set price per item if not positive set to 0 void Invoice::setPricePerItem int price if price gt 0 // if price is positive pricePerItem price // set pricePerItem to price if price lt 0 // if price is not positive pricePerItem 0 // set pricePerItem to 0 cout ltlt quotnpricePerItem cannot be negative. quot ltlt quotpricePerItem set to 0.nquot // end if // end function setPricePerItem // get price per item int Invoice::getPricePerItem return pricePerItem // end function getPricePerItem // calulates invoice amount by multiplying quantity x price per item int Invoice::getInvoiceAmount return getQuantity getPricePerItem // end function getInvoiceAmount 測試函數 include ltiostreamgt using std::cout using std::cin using std::endl // include definition of class Invoice from Invoice.h include quotInvoice.hquot // function main begins program execution int main // create an Invoice object Invoice invoice quot12345quot quotHammerquot 100 5 // display the invoice data members and calculate the amount cout ltlt quotPart number: quot ltlt invoice.getPartNumber ltlt endl cout ltlt quotPart description: quot ltlt invoice.getPartDescription ltlt endl cout ltlt quotQuantity: quot ltlt invoice.getQuantity ltlt endl cout ltlt quotPrice per item: quot ltlt invoice.getPricePerItem ltlt endl cout ltlt quotInvoice amount: quot ltlt invoice.getInvoiceAmount ltlt endl // modify the invoice data members invoice.setPartNumber quot123456quot invoice.setPartDescription quotSawquot invoice.setQuantity -5 //negative quantityso quantity set to 0 invoice.setPricePerItem 10 cout ltlt quotnInvoice data members modified.nnquot // display the modified invoice data members and calculate new amount cout ltlt quotPart number: quot ltlt invoice.getPartNumber ltlt endl cout ltlt quotPart description: quot ltlt invoice.getPartDescription ltlt endl cout ltlt quotQuantity: quot ltlt invoice.getQuantity ltlt endl cout ltlt quotPrice per item: quot ltlt invoice.getPricePerItem ltlt endl cout ltlt quotInvoice amount: quot ltlt invoice.getInvoiceAmount ltlt endl return 0 // indicate successful termination // end main 3.14 類定義 include ltstringgt // program uses C standard string class using std::string // Employee class definition class Employee public: Employee string string int // constructor sets data members void setFirstName string // set first name string getFirstName // return first name void setLastName string // set last name string getLastName // return last name void setMonthlySalary int // set weekly salary int getMonthlySalary // return weekly salary private: string firstName // Employees first name string lastName // Employees last name int monthlySalary // Employees salary per month // end class Employee 類成員函數 include ltiostreamgt using std::cout include quotEmployee.hquot // Employee class definition // Employee constructor initializes the three data members Employee::Employee string first string last int salary setFirstName first // store first name setLastName last // store last name setMonthlySalary salary // validate and store monthly salary // end Employee constructor // set first name void Employee::setFirstName string name firstName name // no validation needed // end function setFirstName // return first name string Employee::getFirstName return firstName // end function getFirstName // set last name void Employee::setLastName string name lastName name // no validation needed // end function setLastName // return last name string Employee::getLastName return lastName // end function getLastName // set monthly salary if not positive set to 0.0 void Employee::setMonthlySalary int salary if salary gt 0 // if salary is positive monthlySalary salary // set monthlySalary to salary if salary lt 0 // if salary is not positive monthlySalary 0 // set monthlySalary to 0.0 // end function setMonthlySalary // return monthly salary int Employee::getMonthlySalary return monthlySalary // end function getMonthlySalary 測試函數 include ltiostreamgt using std::cout using std::endl include quotEmployee.hquot // include definition of class Employee // function main begins program execution int main // create two Employee objects Employee employee1 quotLisaquot quotRobertsquot 4500 Employee employee2 quotMarkquot quotSteinquot 4000 // display each Employees yearly salary cout ltlt quotEmployees yearly salaries: quot ltlt endl // retrieve and display employee1s monthly salary multiplied by 12 int monthlySalary1 employee1.getMonthlySalary cout ltlt employee1.getFirstName ltlt quot quot ltlt employee1.getLastName ltlt quot: quot ltlt monthlySalary1 12 ltlt endl // retrieve and display employee2s monthly salary multiplied by 12 int monthlySalary2 employee2.getMonthlySalary cout ltlt employee2.getFirstName ltlt quot quot ltlt employee2.getLastName ltlt quot: quot ltlt monthlySalary2 12 ltlt endl // give each Employee a 10 raise employee1.setMonthlySalary monthlySalary1 1.1 employee2.setMonthlySalary monthlySalary2 1.1 // display each Employees yearly salary again cout ltlt quotnEmployees yearly salaries after 10 raise: quot ltlt endl // retrieve and display employee1s monthly salary multiplied by 12 monthlySalary1 employee1.getMonthlySalary cout ltlt employee1.getFirstName ltlt quot quot ltlt employee1.getLastName ltlt quot: quot ltlt monthlySalary1 12 ltlt endl monthlySalary2 employee2.getMonthlySalary cout ltlt employee2.getFirstName ltlt quot quot ltlt employee2.getLastName ltlt quot: quot ltlt monthlySalary2 12 ltlt endl return 0 // indicate successful termination // end main 3.15 類定義 class Date public: Date int int int // constructor initializes data members void setMonth int // set month int getMonth // return month void setDay int // set day int getDay // return day void setYear int // set year int getYear // return year void displayDate // displays date in mm/dd/yyyy format private: int month // the month of the date int day // the day of the date int year // the year of the date // end class Date 類成員函數 include ltiostreamgt using std::cout using std::endl include quotDate.hquot // include definition of class Date from Date.h // Date constructor that initializes the three data members // assume values provided are correct really should validate Date::Date int m int d int y setMonth m setDay d setYear y // end Date constructor // set month void Date::setMonth int m month m if month lt 1 month 1 if month gt 12 month 1 // end function setMonth // return month int Date::getMonth return month // end function getMonth // set day void Date::setDay int d day d // end function setDay // return day int Date::getDay return day // end function getDay // set year void Date::setYear int y year y // end function setYear // return year int Date::getYear return year // end function getYear // print Date in the format mm/dd/yyyy void Date::displayDate cout ltlt month ltlt / ltlt day ltlt / ltlt year ltlt endl // end function displayDate 測試函數 include ltiostreamgt using std::cout using std::endl include quotDate.hquot // include definition of class Date.
㈨ 求《C 大學教程》/《C how to program》第5版 課後練習答案
《c大學教程 (Deitle 著) 電子工業出版社 課後答案》
是不是這個?
㈩ C語言程序設計第五版課後習題答案在哪能找到
你可以去看下(答案管家)wx公-眾-號,裡面就有這本。

