IEG 3080 Tutorial One: Course Outline C++ Basics Data Member & Member Function Constructor & Destructor
IEG 3080 Tutorial One: Course Outline C++ Basics Data Member & Member Function Constructor & Destructor
Course Outline
C++ Basics
Data member & Member function
Constructor & Destructor
C++
Better C
e.g. cout vs printf(), vector vs array, const vs #define
e.g. new vs malloc(), inline vs #define, reference vs pointer
Generic Programming
e.g. template, container, iterator, algorithms
A good tool for OOP (Object-Oriented Programming)
Prepared by Brian Lam Tak Cheung 2
Assessment Scheme
Attendance in talk 5%
Don’t loss these marks !
Compilation
In Unix: g++ [source.cpp] -o [output_file]
In Visual Studio: press the compile button
We test the assignments in Unix platform if no explicitly specified.
Why OO?
Model the problem domain which is closer to the real world situation
Decompose the the complex problem into many simpler problems
Different parts/objects of the software can be developed by different
people separately, with low dependency
Code can be reused, which lower the cost and time.
Software can be flexibly modified without large change of code by
add-on, remove, re-arrange or modify limited number of objects,
without affecting other objects.
OO is just like playing LEGO
In C++, class is very similar to struct, and it also include Member Function and
Access Right Label (Private, Public, Protected).
class class_name
{
Private:
data_type data_variable;
……
Public:
void function()
}
For the course IEG 3080, there are three Tutors and an
Instructor. Write a program by C++, so that the
Instructor can judge which tutor is the best tutor.
Step One: Think which object involved
Step Two: What information or characteristics bound to the object
Step Three: Declare the Class (the interface)
Step Four: Implement the functions.
Instructor::~Instructor()
{
Remember to free memory.
delete [] tutor; Otherwise memory leak will
} occur
Destructor