Define a class called MyString with these features:
1) An overloaded binary + operator that concatenates two MyString objects & create a third object.
2) An overloaded comparison == operator to comapre two strings.
3) An overloaded unary - (minus) operator that returns true if the string object is empty otherwise false.
1
Expert's answer
2012-10-08T09:03:10-0400
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace ConsoleApplication1 { public class MyString { & public String plus(String a, String b){ return a + b; & } & public bool compare(String a, String b) & { return a == b; & } & public bool minus(String a) & { return a == ""; & } } class Program { & static void Main(string[] args) & { String a; a = "string"; String b; b = "string"; MyString c = new MyString(); c.compare(a, b); & } } }
Comments
Dear visitor It's a complete code, it should work properly
Is this a complete coding ! Not running the program successfully.
Leave a comment