COP 3502 Introduction to Computer Science Object oriented
COP 3502: Introduction to Computer Science Object oriented programming Yashas Shankar
Object oriented programming Programming style such that you view data, functions, etc as objects Human Left_han d Left_leg Body Right_le g Right_han d
Object oriented programming Human Left_han d Left_leg Left_han d move hand, move finger, swing, etc Left_leg Body Move forward, kick, etc Right_le g Right_han d
Object oriented programming Human Left_han d Left_leg Left_han d move hand, move finger, swing, etc Left_leg Human Body Right_le g Right_han d Move forward, kick, etc Void Walk() { Left_leg. move_forward; walk, etc Right_leg. move_forward }
Objects An object contains both data and functions Functions are usually public data where other function call Data are usually kept private Other functions cannot access that data Only functions in this object and access the data Class football_team{ Public: void touch_down(); Private: int score; };
Objects Class football_team{ Public: void touch_down(); Private: int score; }; Int main() { football_team FSU; FSU. touch_down(); }
Objects Class football_team{ Public: void touch_down(); Private: int score; }; Int main() { football_team FSU; FSU. touch_down(); } void football_team: : touch_down{ score = score + 6; }
- Slides: 7