Uploaded by Ali Jafar

cs 411 lalooo

advertisement
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace cs411
{
class Program
{
static void Main(string[] args)
{
//for sum
Student std1 = new Student();
Student std2 = new Student();
Student std3 = new Student();
// for *
Student std4 = new Student();
Student std5 = new Student();
Student std6 = new Student();
std3 = std1 + std2;
std6 = std4 * std5;
//Printing Sum
Console.WriteLine("Overloading + Operator Result {0}", std3.concat);
//printing Power
Console.WriteLine("Overloading * Operator Result {0}", std6.raiseToPower);
Console.ReadKey();
}
}
class Student
{
public int secondLast = 7;
public int Last = 8;
public String concat = null;
public double raiseToPower = 0;
public Student() {
secondLast = 7;
Last = 8;
}
public static Student operator *(Student s1, Student s2)
{
Student s3 = new Student();
s3.raiseToPower = Math.Pow(s1.secondLast, s2.Last);
return s3;
}
public static Student operator +(Student s1, Student s2)
{
Student s3 = new Student();
s3.concat= s1.secondLast.ToString() +s2.Last.ToString();
return s3;
}
}
}
Download