Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

object oriented programming c++ hey guys need help with this one and yes I do give thumbs up. Thank you! In this lab 6, well

object oriented programming c++

hey guys need help with this one and yes I do give thumbs up. Thank you!

In this lab 6, well explore the nuances of the relation types part-of, has-a, uses-a, depends-on, member-of,... etc. We will show how these relationship can be useful in the context of C++ classes.

Come up four (4) pair of related Classes with their simple definition (i.e. declaration only) out of the above listed eight (8) relationships. The pair of classes in relationship maybe nested declared inside of another class or individually declared, depending on their relationship.

The class of objects can be reused in other relationship. That brings the max count, not min, of classes required is eight (8).

For example, a Customer is associated with a Store:

*note: You are to come up any pair of objects that you like to demonstrate your chosen object relationships.

#include  #include  #include  using namespace std; class Store; class Customer { private: std::string m_name; std::vector m_customer; void addStore(Store *rhs); public: Customer(std::string name) : m_name(name) { } std::string getName() const { return m_name; } friend std::ostream& operator<<(std::ostream &out, const Customer &rhs); friend Store; }; class Store { private: std::string m_name; std::vector m_customer; public: Store(std::string name): m_name(name) { } void addCustomer(Customer *rhs) { } std::string getName() const { return m_name; } friend std::ostream& operator<<(std::ostream &strm, const Store &rhs); }; int main() { }; // an empty main to turn off compiler noise

Lab 6 Object Relationship

To define 4 different object relationships with proper syntax (as demonstrated in Module 6) with no compilation error.

  • Select 4 different types of object relationship out of 8 listed in Module 6.
  • For each of the 4 relationships you may create any two objects and these classes can be use for different relationships.
  • The class of objects can be reused in other relationship. That brings the max count, not min, of classes required is eight (8).
  • Create the Class declaration header and place ahead of a main app
  • Save the whole file as one .cpp file for all classes used in each of the 4 object relationships (i.e. 4 pair of class declarations)
  • You must provide the necessary information in your comment on the relationship between objects.

Submit

  • lab6_object_relationship.cpp source file contains four (4) pair of different object relationship, properly commented and no compilation error

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books