From 0cac475b4a587ba1b11d911fab931db26e75011e Mon Sep 17 00:00:00 2001 From: mohibqureshi Date: Mon, 7 Oct 2019 14:17:12 +0530 Subject: [PATCH 1/2] Added Object_Oriented_Programming directory and string simulation with the same. --- .../Object_Oriented_programming/string.cpp | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Algorithms/Object_Oriented_programming/string.cpp diff --git a/Algorithms/Object_Oriented_programming/string.cpp b/Algorithms/Object_Oriented_programming/string.cpp new file mode 100644 index 0000000..f147595 --- /dev/null +++ b/Algorithms/Object_Oriented_programming/string.cpp @@ -0,0 +1,136 @@ +#include +using namespace std; +class String +{ +private: + char *strArray; + int length; +public: + String () + { + strArray= NULL; + length=0; + } + String (char *char_arr) + { + if (char_arr == NULL) + { + strArray = nullptr; + return; + } + int count=0; + char *p =char_arr; + while (*p != '\0') + { + count++; + p++; + } + length=count; + strArray = new char[count + 1]; + for (int i = 0; i < count; i++) + { + strArray[i] = char_arr[i]; + } + strArray[count]='\0'; + } + String (int len) + { + length = len; + strArray = new char[len + 1]; + } + + String (String &ob1) + { + cout<<"copy constructor"; + int l=getLength(); + ob1.strArray = new char[l + 1]; + for(int i=0;i>s1; + char s2[100]; + cout<<"enter second string\n"; + cin>>s2; + String opp1(s1); + String opp(s2); + st1 = opp1 + opp; + cout<<"concatenated string "<most){ + most=co[i]; + ind=i; + } + } + cout<<"string after removal most occuring character\n"; + for (int m=0;m Date: Mon, 7 Oct 2019 14:20:30 +0530 Subject: [PATCH 2/2] Added Object_Oriented_Programming directory and string simulation with the same. --- Algorithms/Object_Oriented_programming/string.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Algorithms/Object_Oriented_programming/string.cpp b/Algorithms/Object_Oriented_programming/string.cpp index f147595..bdee254 100644 --- a/Algorithms/Object_Oriented_programming/string.cpp +++ b/Algorithms/Object_Oriented_programming/string.cpp @@ -1,3 +1,4 @@ +//string manipulations using oopss #include using namespace std; class String