[英]struct Cat(string, string, bool, bool)' must declare a body because it is not marked abstract, extern, or partial
Here's my code, I have no idea what is wrong and why does the compiler say that 这是我的代码,我不知道出什么问题了,为什么编译器会说
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _11._2
{
class Cat
{
private string name = "cat";
private string type = "gizei";
private bool water = false;
private bool yalel = false;
public Cat(string name, string type, bool water, bool yalel);
public string meow()
{
if (yalel)
return "Meow Meow Meow";
else
return "Meow";
}
public bool thirsty()
{
return water ? true : false;
}
public string info()
{
return "My name is " + name + " and my type is " + type;
}
}
}
I tried adding abstract or external but the error is still there.. 我尝试添加抽象或外部,但错误仍然存在。
This is due to the following line : 这是由于以下行:
public Cat(string name, string type, bool water, bool yalel);
This is a constructor declaration, so you have to declare a body for this method : 这是一个构造函数声明,因此您必须为此方法声明一个主体:
public Cat(string name, string type, bool water, bool yalel)
{
// Do something like :
// this.name = name;
// this.type = type;
// etc...
}
try this 尝试这个
public Cat(string name, string type, bool water, bool yalel)
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.