varshasharat
January 8th, 2011, 05:32 AM
using System;
using System.Collections;
class school
{
String clname;
int tot_stu;
public void get()
{
Console.WriteLine("Enter class name");
clname=Console.ReadLine();
Console.WriteLine("Enter the total no.of students");
tot_stu=Convert.ToInt32(Console.ReadLine());
}
public void put()
{
Console.WriteLine("Maximum no.of students in {0} is {1}",clname,tot_stu);
}
public static bool operator >(school stud1,school stud2)
{
if(s1.tot_stu<s2.tot_stu)
return true;
else
return false;
}
}
public class student
{
public static void Main()
{
school c1,c2,c3;
c1=new school();
c2=new school();
c3=new school();
c1.get();
c2.get();
c3.get();
if(c1>c2)
if(c1>c3)
c1.put();
else
c3.put();
else
if(c2>c3)
c2.put();
else
c3.put();
}
}
student.cs(22,21): error CS0216: The operator 'school.operator >(school,
school)' requires a matching operator '<' to also be defined
using System.Collections;
class school
{
String clname;
int tot_stu;
public void get()
{
Console.WriteLine("Enter class name");
clname=Console.ReadLine();
Console.WriteLine("Enter the total no.of students");
tot_stu=Convert.ToInt32(Console.ReadLine());
}
public void put()
{
Console.WriteLine("Maximum no.of students in {0} is {1}",clname,tot_stu);
}
public static bool operator >(school stud1,school stud2)
{
if(s1.tot_stu<s2.tot_stu)
return true;
else
return false;
}
}
public class student
{
public static void Main()
{
school c1,c2,c3;
c1=new school();
c2=new school();
c3=new school();
c1.get();
c2.get();
c3.get();
if(c1>c2)
if(c1>c3)
c1.put();
else
c3.put();
else
if(c2>c3)
c2.put();
else
c3.put();
}
}
student.cs(22,21): error CS0216: The operator 'school.operator >(school,
school)' requires a matching operator '<' to also be defined