SHARE
TWEET

string_EX2

hainam139 Mar 10th, 2012 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. using namespace std;
  3. class strbyme
  4. {
  5.         private:
  6.         char* s;
  7.         public:
  8.         strbyme()
  9.         {
  10.                 s=new char[1];
  11.                 s[0]='\0';
  12.         }
  13.         strbyme(char* a)
  14.         {
  15.                 s=new char[strlen(a)+1];
  16.                 strcpy(s,a);
  17.         }
  18.         void display()
  19.         {
  20.                 cout<<s<<endl;
  21.         }
  22.         ~strbyme()
  23.         {
  24.                 delete [] s;
  25.         }
  26. };
  27. int main()
  28. {
  29.         char* b;
  30.         b= new char[100];
  31.         cout<<"Input your string:";
  32.         cin.getline(b,100);
  33.         strbyme str(b);
  34.         str.display();
  35.         return 0;
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top