OOP-18CLC1-2-W03 Contructor-Destructor
OOP-18CLC1-2-W03 Contructor-Destructor
Week03
Contructor - Destructor
Cảm ơn thầy Trần Duy Quang đã cung cấp template cho môn học
1
Notes
Create a single solution/folder to store your source code in a week.
Then, create a project/sub-folder to store your source code of each assignment.
The source code in an assignment should have at least 3 files:
• A header file (.h): struct definition, function prototypes/definition.
• A source file (.cpp): function implementation.
• Another source file (.cpp): named YourID_Ex01.cpp, main function. Replace 01 by id of an
assignment.
• Image of commit list
Make sure your source code was built correctly. Use many test cases to check your code before
submitting to Moodle.
Name of your submission: StudentID_Week03_XX.zip. XX: number of assignments you have done.
XX: 00 – 99.
2
OOP W02 – Object & Class
2
Content
In this lab, we will review the following topics:
• Implement classes, attributes and methods in C++.
• Implement contructor, destructor
3
OOP W02 – Object & Class
3
Assignments
Draw 3 contructor and destructor for each of the following class.
3.1. Assignment 1
Write a console application to load an array of fractions from a text file. Find the sum of them. Find the
maximum and the minimum of them. Sort the array in ascending order.
3.2. Assignment 2
Write a console application to load an array of points (Oxy plane) from a text file. Allow user to input a
point P. Find an element in the array that the distance from it to P is longest.
3.3. Assignment 3
Write a console application to load an array of triangles from file. Remove all invalid triangles. How
many invalid triangles did you have to remove? How many equilateral triangles? Right isosceles
triangle? Right triangles? Acute triangles? Obtuse triangles? are there in the array?
3.4. Assignment 4
Write a console application to input a date (day, month, and year). Output to screen the date before
(yesterday), the date after (tomorrow).
3.5. Assignment 5
Write a console application to input a time (hour, minute, second). Increase the time to one second and
output to screen. What is the result if we decrease the time to one second?
3.6. Assignment 6
Write a console application to load an array of students (id, full name (first name and last name),
address, date of birth, mark) from text file. Sort them by their last name and write the array to and XML
file.
4
OOP W02 – Object & Class
4
In class assignment (A)
2 assignment (source code in C++)
5
OOP W02 – Object & Class
5
Homework (H)
All problems/assignments.