C++ 错误c3867,不确定我需要做什么来修复

C++ 错误c3867,不确定我需要做什么来修复,c++,compiler-errors,C++,Compiler Errors,我得到了一些错误c3867(当试图编译下面的代码时 例如: “错误C3867:'Animal::sleep':函数调用缺少参数列表;使用“&Animal::sleep”在hammertime.sleep第47行创建指向成员”的指针 #include "stdafx.h" #include <iostream> #include <string> using namespace std; class Animal { protected: int age;

我得到了一些错误c3867(当试图编译下面的代码时

例如:

“错误C3867:'Animal::sleep':函数调用缺少参数列表;使用“&Animal::sleep”在hammertime.sleep第47行创建指向成员”的指针

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

class Animal
{
protected:
    int age;
    string type;
public:
    void sleep() { cout << type << " : Sleeping" << endl; }
    void eat() {cout << type << " : Eating" << endl; }
    int getAge() { return age; }
    string getType() { return type; }
    Animal(int argAge) : age(argAge) {}
    Animal() : age(0),type("Animal") {}
    Animal::Animal(int, string);
};

class Lion : Animal
{
public:
    void sleep() { cout << "The lion is sleeping" << endl; }

};

class Hamster : Animal
{
public:
    void eat() { cout << "The hamster is eating" << endl; }
};

char YorN;
string aniType;
int eatOrSleep = 0;
int check = 0;


int main()
{
    Lion scar;
    scar.eat;

    Hamster hammertime;
    hammertime.sleep;

    cout << "Would you like to create a new animal? y/n" << endl;
    cin >> YorN;
    if (YorN == 'y' || YorN == 'Y'){
        cout << "What kind of animal?:" << endl;
        cin >> aniType;
        Animal newAnimal(0,aniType);
        cout << "Congratualtions, you just created a" << newAnimal.getType << endl;
        do
        {
            cout << "Enter either 1, 2 or 3:" << endl <<
                "1: Makes your animal sleep" << endl <<
                "2: Makes your animal eat" << endl <<
                "3: Exit the program" << endl;
            cin >> eatOrSleep;
            if (eatOrSleep == 1)
            {
                newAnimal.sleep;
            }
            else if (eatOrSleep == 2)
            {
                newAnimal.eat;
            }
            else if (eatOrSleep == 3)
            {
                check = 1;
                break;
            }
        } while (check == 0 );

    }

    return 0;
}
#包括“stdafx.h”
#包括
#包括
使用名称空间std;
类动物
{
受保护的:
智力年龄;
字符串类型;
公众:

void sleep(){cout例如,以以下代码为例:

if (eatOrSleep == 1)
{
    newAnimal.sleep;
}
else if (eatOrSleep == 2)
{
    newAnimal.eat;
}

newAnimal.sleep
newAnimal.eat
是函数。要调用它们,需要使用语法
newAnimal.sleep()
newAnimal.eat()

方法调用需要参数,例如:
hammertime.sleep();
还需要声明sleep(以及任何被其子级覆盖的方法)虚拟的。