programs of concate two string:
#include<iostream> #include<string.h> using namespace std; class A{ char name[10]; public: void set_name(char *na){ strcpy(name,na); } A operator +(A&obj){ A obj3; strcpy(obj3.name,strcat(name,obj.name)); return obj3; } char* get_c(){ return name; } }; int main(){ A obj,obj2,obj3; char name[]="hello"; obj.set_name(name); char name1[]="hii"; obj2.set_name(name1); obj3=obj+obj2; cout<<obj3.get_c(); }
hellohii
If you like code with vibhu and would like to contribute, you can also write an article using This link :
https://docs.google.com/forms/d/e/1FAIpQLScAmvlPvNUz35R-G0nc_zpRVP3o8xlhtFgC3aKPyLetX_RyXg/viewform?pli=1
OR mail your article to bibhutiswain990@gmail.com. See your article appearing on the code with vibhu main page and help other students.
0 Comments