Others already pointed out the problem of ->
vs. dot (.
) syntax.
But I'd like to elaborate a bit on other sides.
Since you are initializing your OfferingPair::off
and nextOff
data members to NULL
, maybe this work should be done inside OfferingPair
default constructor:
struct OfferingPair
{
....
OfferingPair()
: off(NULL)
, nextOff(NULL)
{
}
};
And you can just use a std::vector
instead of a raw C-like array to store instances of the above structure.
Add a data member to your Schedule
class like this:
std::vector<OfferingPair> m_weeklySchedule;
And then in the default constructor create a std::vector
of 5 items:
Schedule::Schedule()
: m_weeklySchedule(5)
{
}
Note how your code is simplified.
Note also that you don't need an explicit delete[]
in your destructor to release the array dynamically allocated memory: std::vector
's destructor will be automatically called and will take care of that.
Moreover, the compiler generated copy constructor and copy operator=
will do the right thing with member-wise copy (calling the corresponding std::vector
copy operations), instead with a raw C-like array you have to write proper code for copy constructor and operator=
(or ban them, declaring them private
).
EDIT:
You seem to have edited your original post adding new code, in particular some sketch of the OfferingPair
data structure:
struct OfferingPair
{
Offering * off;
OfferingPair * nextOff;
};
The fact that you have a pointer to the next OfferingPair
inside OfferingPair
makes me think that maybe you just need a linked list of Offering
's? Unless this is a learning exercise for linked lists, maybe you just need a std::list<Offering>
, or a C++11 std::forward_list<Offering>
?