I have 2 classes
class Book
{
public:
int _pages;
string* _name;
};
class Shelf
{
public:
int shelfName;
int _booksCount;
book** _books;
};
(with more irrelevant function and variables)
and I want to create function which will calculate the total pages on the shelf, i am new OOP so that what i tried to do:
double Shelf:: getAvg()
{
int sum, i;
for (int i = 0; i < __bookCount-1; i++)// the count not considering inedx 0
{
sum += _books[i]._pages;// need to be fixed<<
}
}
I am pretty sure the only problem is the last line syntax, can you please guide me how to correct it? thank in advance