0

Your company built an in-house calendar tool called HiCal. You want to add a feature to see the times in a day when everyone is available.

To do this, you’ll need to know when any team is having a meeting. In HiCal, a meeting is stored as an instance of a Meeting class with integer member variables startTime and endTime. These integers represent the number of 30-minute blocks past 9:00am.

  class Meeting
{
private:
    // number of 30 min blocks past 9:00 am
    unsigned int startTime_;
    unsigned int endTime_;

public:
    Meeting() :
        startTime_(0),
        endTime_(0)
    {
    }

    Meeting(unsigned int startTime, unsigned int endTime) :
        startTime_(startTime),
        endTime_(endTime)
    {
    }

    unsigned int getStartTime() const
    {
        return startTime_;
    }

    void setStartTime(unsigned int startTime)
    {
        startTime_ = startTime;
    }

    unsigned int getEndTime() const
    {
        return endTime_;
    }

    void setEndTime(unsigned int endTime)
    {
        endTime_ = endTime;
    }

    bool operator==(const Meeting& other) const
    {
        return
            startTime_ == other.startTime_
            && endTime_ == other.endTime_;
    }
};

My Doubt is that i don't understand the syntax of this piece of code, In c++ we don't define a function as Meeting(): Right? It is python syntax Right? Can someone please explain it.

source:https://www.interviewcake.com/question/cpp/merging-ranges?course=fc1&section=array-and-string-manipulation

Sanjay Verma
  • 101
  • 13
  • 4
    Seems like you should get good [C++ books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). You can't learn C++ by cherry-picking topics here and there -- it is a complex language that cannot be learned this way. – PaulMcKenzie Jun 18 '20 at 07:27
  • Yes you're right sir, Thanks for the list. – Sanjay Verma Jun 18 '20 at 07:31
  • Btw, `Meeting()` is the constructor of the class `Meeting`. I agree with @PaulMcKenzie – Louis Go Jun 18 '20 at 07:40
  • _"In c++ we don't define a function as Meeting(): Right?"_ Wrong. The provided code is valid C++ code. _"It is python syntax Right?"_ Wrong, Python code looks very different. – Thomas Sablik Jun 18 '20 at 08:05

0 Answers0