323x Filetype PDF File size 1.53 MB Source: www.cse.iitb.ac.in
CS 101:
Computer Programming and
Utilization
Puru
with
CS101 TAs and Staff
Course webpage: https://www.cse.iitb.ac.in/~cs101/
Lecture 20:C++ and object oriented programming
CS101 Autumn 2019 @ CSE IIT Bombay
Object Oriented Programming
A methodology for designing programs
CS101 Autumn 2019 @ CSE IIT Bombay 2
The C++ structure
• Member variables
− Basic facility provided in C++ to conveniently gather together
information associated with an entity
− Inherited from the C language
• Member functions
− New feature introduced in C++
− Actions/operations that effect the entity
− User defined data type with variables and functions
CS101 Autumn 2019 @ CSE IIT Bombay 3
Nested structures (structure is a data type!)
struct Point{
double x,y;
};
struct Disk{
Point center; // contains Point
double radius;
};
Disk d;
d.radius = 10;
d.center = {15, 20};
// sets the x {member of center member of d
CS101 Autumn 2019 @ CSE IIT Bombay 4
no reviews yet
Please Login to review.