CS 70

Semicolon at the End!

  • LHS Cow speaking

    A class definition ends in a semicolon!

  • RHS Cow speaking

    Don't forget the semicolon!

cow.hpp:

/*
 * \file cow.hpp
 * \author CS 70 Provided Code
 * \brief Interface definition for the Cow class.
 */

#ifndef COW_HPP_INCLUDED
#define COW_HPP_INCLUDED

#include <iostream>
#include <fstream>

/*
 * \class Cow
 * \brief Knows how many spots it has & how old it is. Can moo.
 */
class Cow {
 public:
    // We can only have a Cow if we know
    // how many spots it has and how old it is
    Cow(int numSpots, int age);
    Cow() = delete;

    // Moo the right number of times.
    void moo(int numMoos) const;

    // Accessor member functions
    int getNumSpots() const;
    int getAge() const;

    // Mutator member functions
    void setNumSpots(int numSpots);
    void setAge(int age);

 private:
    // Per-Cow data
    int numSpots_;
    int age_;
};

#endif  // ifndef COW_HPP_INCLUDED
  • LHS Cow speaking

    See the semicolon?

  • RHS Cow speaking

    Don't forget the semicolon!

  • LHS Cow speaking

    There are not many circumstances where you type }; so it's easy to forget and just type } and a new line, which feels more natural.

  • RHS Cow speaking

    So please remember: class definitions end in a semicolon.

What does a class definition end with?

(When logged in, completion status appears here.)