CSEE2123: OOP and Data Structures: Fall 2018
CSEE2123: OOP and Data Structures: Fall 2018
Fall 2018
Object Oriented Programming(OOP),
Classes
Lecture 6
M. Tahir Awan
([email protected])
Capital University of Science & Technology (CUST),
Islamabad
Assignment # 1 :
Programming Assignment
• Due Date :
– Friday, October 12th , 2018
– Due at : 05:00 p.m.
• Late Submission
– Not Allowed
• Assignment Submission
– Separate *.cpp file for each Question
– Submit in zip format
– File name : “Name_RollNo_AssignNo.zip”
– Submission Path
» \\fs\assignments$\mTahir\Assignment1
User-Defined Data
Types
public:
Circle() {
radius = 5.0;
}
float getArea() {
return radius* radius* 3.14159;
}
};
int getX() {
return x; }
};
}
int main() {
Complex c1, c2(4, 5);
c1.setReal(0);
c1.setImag(8);
• Time Class
• Primitives : hours, minutes, seconds type int
• Student Class
• Primitives : Name of type string, marks of type
int , grade of type char
10/4/2018 CSEE1133:Data Structures © M. Tahir Awan, CUST 23
Constructor Overloading
• In C++ multiple constructors can be defined
within a class. Concept is known as constructor
overloading
• Compiler will differentiate between multiple
constructors depending upon number of
arguments in constructor definition
• Constructor Overloading is used to increase the
flexibility in variable initialization
Complex() Complex( float r, float i)
{ {
real = 0.0; real = r;
imag = 0.0; imag = i;
} }