Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string.h>
- using namespace std;
- class String
- {
- char *p;
- int len;
- public:
- String(const char *a);
- };
- String::String(const char *a)
- {
- int length = strlen(a);
- p = new char[length +1];
- strcpy(p, a);
- cout << "Constructor Called " << endl;
- }
- int main()
- {
- String s1("Geeks"); // line 1
- const char *name = "forGeeks";
- s1 = String(name); // line 3
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement