博文

目前显示的是 二月, 2012的博文

把C++看完了

图片
紧赶慢赶,不到半个月,把《C++面向对象程序设计》看完了,书里有的,基本上都了解了。把看书的时候做的笔记、编写的程序,整理成了一个PDF,将近100页,准备开学作为免修的材料。 明天要出去跟朋友玩,周一又要开始上班,只能等到下周末去首图了,想看看《C++ Primer》,把《C++面向对象程序设计》中没有讲的东西补充下。 一开始还担心开学前看不完学校这本书,现在还有半个月的时间,可以放松下来了。可以去看看《洛丽塔》和《青春》咯! 最后附上一张照片,璇儿生日那天拍的:

Homework of Chapter Polymorphism and Virtual Function

Homework: Define a virtual base class Shape, then derive five class: Circle, Square, Rectangle, Trapezoid and Triangle. Using virtual funciton to work out and display the area of every graph. And get the sum of these graphs. Tomorrow, oh no, it has, I will learn the last but one Chapter:I/0 stream. Also, hope it is not too difficult. #include <iostream> #include <cmath> using namespace std; const float Pi=3.14; class Shape { public: Shape(){} virtual float getAreaValue() const { return 0.0; } virtual void printArea() const = 0; }; class Circle : public Shape { public: Circle() { radius=0.0; } Circle(float r) { radius=r; } virtual void printArea() const; virtual float getAreaValue() const; private: float radius; }; void Circle::printArea() const { cout << "Circle Area:"; cout << P