中国高校课件下载中心 》 教学资源 》 大学文库

《面向对象程序设计》课程教学资源(Exercise)4

文档信息
资源类别:文库
文档格式:DOC
文档页数:1
文件大小:30KB
团购合买:点击进入团购
内容简介
Exercises 4(280) 1.Create a Text class that contains a string object to hold the text of a file. Give it two constructors: a default constructor and a constructor that takes a string argument that is the name of the file to open. When the second constructor is used, open the file and read the contents into the string
刷新页面文档预览

Exercises 4 (280) 1, Create a Text class that contains a string object to hold the text of a file. Give it two constructors a default constructor and a constructor that takes a string argument that is the name of the file to open. When the second constructor is used, open the file and read the contents into the string member object. Add a member function contents()to return the string so(for example) it can be printed. In main(), open a file using Text and print the contents 2, Create a new version of the Stack class that contains the default constructor as before, and a second constructor that takes as its arguments an array of pointers to objects and the size of that array. This constructor should move through the array and push each pointer onto the Stack, Test your class with an array of string

Exercises 4 (280) 1、Create a Text class that contains a string object to hold the text of a file. Give it two constructors: a default constructor and a constructor that takes a string argument that is the name of the file to open. When the second constructor is used, open the file and read the contents into the string member object. Add a member function contents( ) to return the string so (for example) it can be printed. In main( ), open a file using Text and print the contents. 2、Create a new version of the Stack class that contains the default constructor as before, and a second constructor that takes as its arguments an array of pointers to objects and the size of that array. This constructor should move through the array and push each pointer onto the Stack. Test your class with an array of string

已到末页,全文结束
刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档