Giter Site home page Giter Site logo

cosc1430_exercise1's Introduction

COSC1430_Exercise1

Given a class FamilyVacation below

class FamilyVacation
{
   public:
        void  SetNumDays(int dayCount);
        void  SetNumPeople(int peopleCount);
        void  SetNames(string [], int);
        void  Print() const;
        FamilyVacation operator+(int moreDays);
   private:
        int   numDays;
        int   numPeople;
        string *names;
  };

Define three constructors:

·A default constructor that sets the default values for the three members as numDays=0, numPeople=0, names = nullptr
·An overloaded constructor that takes three parameters as input in the order of (int days, int people, string *names)
·A copy constructor that properly handles the deep copy of the member variable *names
·Define a destructor that releases the memory of the *names member variable.

Overload the following operators:

·A '+' operator that allows the calculation of newVacation = oldVacation + 5; (both newVacation and oldVacation are objects of FamilyVacation). This calculation will return a new vacation with 5 more days (i.e., add 5 to numDays member).
·A '+' operator that allows the calculation of newVacation = Vacation1 + Vacation2;, which will add the numDays of the Vacation1 and Vacation2 and merge the names lists of the two objects
·A '==' operator that compares two FamilyVacation objects, i.e., Vacation1 == Vacation2;,. If the two objects have identical numDays, numPeople and names lists, the function return true; otherwise, it returns false
·The '<<' operator that enables the direct output of FamilyVacation object as cout << myVacation;
·The '=' operator that assign a FamilyVacation object to another using deep copy

cosc1430_exercise1's People

Contributors

ohaluminum avatar

Forkers

drgkm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.