tailieunhanh - C++ Review

C++ Review presents about C++ is a superset of C, Some C++ code, Header Guards, Circular Includes, Forward Declarations, Allocating memory using new, Deallocating memory using delete, Using new with arrays. | C++ Review Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Acknowledgement: Adapted from: Brown CS123 1 C++ Review Part 1: Mechanics 2 C++ is a superset of C • New Features include – Classes (Object Oriented) – Templates (Standard Template Library) – Operator Overloading – Slightly cleaner memory operations 3 Some C++ code #ifndef __SEGMENT_HEADER__ #define __SEGMENT_HEADER__ #include "" #include "" class Point; class Segment { public: Segment(); virtual ~Segment(); private: Point *m_p0, *m_p1; }; Segment::Segment() { m_p0 = new Point(0, 0); m_p1 = new Point(1, 1); } Segment::~Segment() { delete m_p0; delete m_p1; } #endif // __SEGMENT_HEADER__ 4 #include #include "" Insert header file at this point. #include Use library .