(CustomclassIntChar,savealengthnotexceeding4stringwithaninteger.Supposeacharacterlengthis1byte.*Forexample:"ABCD",keptbyaninteger,binaryform:0,100,000,101,000,0100100001101000100*lengthoflessthanfourcharactersofthestring,therestofcomplementwith0.The***theneedclassIntCharofthepropertiesandmethods,butmustmeetthefollowingrequirements:*1.InclassIntChar,cannotusethestringtypetheC++languagetodefineanyattributes(variables).*2.DefinedclassIntChar,themainfunctioncanbeusedfollowingwaysIntChar:**voidmain(){IntCharIC("Love")*IC.ASC_Print()//incharactersstringdisplayedintheformsavedintheobjectIC*IC.Binary_Print()//savethecontentsoftheobjectIC*IC.Int_Print()inbinaryform//integersavedintheobjectIC*}) - IMDN开发者社群-imdn.cn">
登录
首页 » C/C++ » 定义类IntChar Exercise-1-IntChar

定义类IntChar Exercise-1-IntChar

于 2013-05-11 发布 文件大小:1KB
0 86
下载积分: 1 下载次数: 4

代码说明:

  定义类IntChar,实现用一个整数保存一个长度不超过4的字符串。假设一个字符长度是1个字节。 * 例如:"ABCD",用一个整数保存,其二进制形式为:0100 0001 0100 0010 0100 0011 0100 0100 * 长度不足四个字符的串,剩下部分用0补足。 * * * 自己根据需要类IntChar的属性和方法,但需满足以下要求: * 1. 在类IntChar中,不能用C++语言中的string类型来定义任何属性(变量)。 * 2. 对于定义的类IntChar,在main函数中,能用以下方式使用类IntChar: * * void main() * { * IntChar IC("Love") * IC.ASC_Print() // 以字符串形式显示对象IC中保存的内容 * IC.Binary_Print() // 以二进制形式显示对象IC中保存的内容 * IC.Int_Print() // 以整数形式显示对象IC中保存的内容 * }(Custom class IntChar, save a length not exceeding 4 string with an integer. Suppose a character length is 1 byte.* For example: " ABCD" , kept by an integer, binary form: 0,100,000,101,000,010 0100 0011 0100 0100* length of less than four characters of the string, the rest of complement with 0. The*** the need class IntChar of the properties and methods, but must meet the following requirements:* 1. In class IntChar, can not use the string type the C++ language to define any attributes (variables).* 2. Defined class IntChar, the main function can be used following ways IntChar:** void main () {IntChar IC (" Love" ) * IC.ASC_Print () // in characters string displayed in the form saved in the object IC* IC.Binary_Print () // save the contents of the object IC* IC.Int_Print () in binary form // integer saved in the object IC*})

文件列表:

Exercise 1:IntChar.txt,994,2013-05-02

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 696518资源总数
  • 104349会员总数
  • 32今日下载