CO203 Study Guide - Midterm Guide: Object-Oriented Programming, Member Variable, Memory Address

10 views10 pages
25 Feb 2023
Department
Course
Professor

Document Summary

In object-oriented programming (oop), an object is an instance of a class. A pointer to an object is a variable that contains the memory address of an object. We can use pointers to objects to access the member functions and member variables of an object. For example, we can define a pointer to an object of class "myclass" as follows: We can then use the arrow operator (->) to access the member functions and member variables of the object: ptr->memberfunction(); ptr->membervariable = 42; We can create an array of objects in c++ by declaring an array of class type. For example, we can create an array of 10 objects of class "myclass" as follows: We can then access the individual objects in the array using the array index notation: s myarray[0]. memberfunction(); myarray[1]. membervariable = 42; We can also use pointers to access the member variables of an object.