03 2013 档案
摘要:DescriptionDesign a class named Point to represent a point in the plane, and a class named Segment to represent a segment.Using the class interface as followsclass Point{public: Point(double x, double y); void setX(double x); void setY(double y); double getX(); double getY(); private: doub...
阅读全文
摘要:DescriptionRewrite Exercise 7.18 using the string class with the following function header:bool isAnagram(const string &s1, const string &s2)Two words are anagrams if they contain the same letters in any order.自己班的作业写到烦了又跑去蹭别人班的题做……因为这是道改编题,不知道原题的要求是什么,纠结了很久=。=这里的anagram的要求应该是两个字符串具有相同的字符,每种
阅读全文
摘要:Description通过完成类的定义及其实 现:ClassWithCounter,使用下面提供的主函数,可以得到Sample Output中的输出。鉴于大家还没有学习到static成员变量,在你的代码中可以采用全局变量做对象个数的统计。简单地讲,该全局变量初始为0,在 每个构造函数中自增1。在该类中,有一个成员变量记录着自己是第几个。Output在 默认的构造函数中输出如下内容:ClassWithCounter::ClassWithCounter(): id。(注意冒号与id间有一个空格,输出一行)。在析构函数中输出一下内 容:ClassWithCounter::~ClassWithCoun
阅读全文
摘要:Description“ 只要我离开了你的世界,无论你做过什么,我都能忘记你回到从前!”小PY今天很小清新的,大家不要说他腹黑啊。他知道今天大家都学习了析构函数!现在请大 家帮他实现一个类AutoReset,这个类的功能是在一个作用域开始的时候,保存某个变量的值,而当该作用域结束的时候能够实现变量值的Reset。比 如以下这个例子:实现下面这个类:class AutoReset {public: AutoReset(int *scoped_variable, int new_value); ~AutoReset();private: int *scoped_variable_; int ori
阅读全文
摘要:DescriptionDesign a class name Time. The class contains:Data field hour, minute, and second that represent a time.A no-arg constructor that creates a Time object for the current time. (The data fields value will represent the current time.)A constructor that constructs a Time object with a specified
阅读全文

浙公网安备 33010602011771号