0% found this document useful (0 votes)
45 views6 pages

Objects and Arrays: OOC 4 Sem, B' Div 2016-17 Prof. Mouna M. Naravani

The document discusses arrays of objects and arrays inside objects in C++. It is possible to create arrays that contain objects as elements. Each object in the array can then be accessed and have methods called on it. An array declared inside a class becomes a member of all objects of that class and can be accessed by member functions.

Uploaded by

sumahals
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views6 pages

Objects and Arrays: OOC 4 Sem, B' Div 2016-17 Prof. Mouna M. Naravani

The document discusses arrays of objects and arrays inside objects in C++. It is possible to create arrays that contain objects as elements. Each object in the array can then be accessed and have methods called on it. An array declared inside a class becomes a member of all objects of that class and can be accessed by member functions.

Uploaded by

sumahals
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Objects and Arrays

OOC
4th Sem, ‘B’ Div
2016-17
Prof. Mouna M. Naravani
Array of Objects
➢ It is possible to create array of objects.
➢ We can have arrays of variables that are of the type class. Such variables are called
arrays of objects.
Ex:
class employee
Creating array of objects:
{
char name[20]; employee manager[3]; // array of manager
float age;
employee worker[75]; // array of worker.
public:
void getdata(); ➢ The array of manager contains three objects,
void putdata();
manager[0], manager[1] and manager[2].
}
Accessing array of objects

manager[i].getdata(); Ex: ArrayOfObj.cpp

manager[i].putdata();

Storage of array of objects

name
manager[0]
age

name
manager[1]
age

name
manager[2]
age
Arrays inside Objects
➢ An array can be declared inside a class.
➢ Such an array becomes a member of all objects of the class.
➢ It can be manipulated/accessed by all member functions of the class.
Ex:
class example
{
int arr[10];
-------
-------
}
References

➢ Sourav Sahay, “Objected Oriented Programming with C++”

➢ E Balagurusamy, “Objected Oriented Programming with C++”

You might also like