复数相加程序无法调用方法
namespace ConsoleApplication6{
class class1
{
private int real;
private int image ;
class1()
{
real = 0;
image = 0;
}
void accept()
{
Console.WriteLine("请输入实数部分");
real = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入虚数部分");
image = Convert.ToInt32(Console.ReadLine());
}
class1 add(class1 cin)
{
cin.real += this.real;
cin.image+= this.image;
return cin;
}
void show()
{
Console.WriteLine("两数相加之和为"+this.real+"+"+this.image+"i");
}
static void Main(string[] args)
{
class1 c1 = new class1();
class1 c2 = new class1();
c1.accept;
c2.accept;
class1 temp = new class1();
temp = c1.add(c2);
temp.show;
}
}
}
在最后的主程序处报错,就是 c1.accept;
c2.accept;
temp.show;
这几个地方报错,报错内容为:"只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句 "
希望高手给你解决
--------------------编程问答-------------------- c1.accept();
c2.accept();
--------------------编程问答-------------------- 谢谢 --------------------编程问答--------------------
是啊,程序员需要自己排错啊,这样的错误,自己再仔细一点就可以看见啊
补充:.NET技术 , C#