Converting base type to class type (char to string), C/C++ Programming

Converting Base Type to Class Type (char to string)


class String

{ char *name;

int length;



{length =0;

name = new char[length+1];


String(char *s)

{length = strlen(s);

name = new char[length+1];//for null terminator strcpy(name,s);


void display(void)



void join(String &a, String &b);

friend String operator+(String &a, String &b);


String operator+(String &a, String &b)

{String temp;


temp.length = a.length+b.length; = new char[temp.length+1]; strcpy(,; strcat(,;

return temp;



void String::join(String &a, String &b)

{length = a.length+b.length;

delete name;

name = new char[length+1];




void main()


char *first="Electronic ";

String name1(first); String name2("and Communication ");String name3("Engineering");

String s1,s2; s1.join(name1,name2); s2.join(s1,name3); s1=name1+name2; s2=s1+name3;






Posted Date: 9/20/2012 8:19:55 AM | Location : United States

Related Discussions:- Converting base type to class type (char to string), Assignment Help, Ask Question on Converting base type to class type (char to string), Get Answer, Expert's Help, Converting base type to class type (char to string) Discussions

Write discussion on Converting base type to class type (char to string)
Your posts are moderated
Related Questions
what are assessor. elaborate with clear easy diagrams

C Program for FUNCTION OF COUNT THE CHARACTERS IN EACH WORD void count(char c[]); void main() {           char a[50];           int i=0;           clrscr();

Need someone to look over my assignment for correctness and make any necessary changes.

C Program for Palindrome Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

C program to demonstrate call by reference: void disp(int *,int*,int*,int*); void main() {                 int a=2,b=3, sum,mul;                 printf("Enter 1st n

You are to write a C++ program which will compute the gross pay, Social Security Tax, Income Tax and net pay for an employee. The program needs to prompt for and read the employ

MAT LAB programming Project Description: Just for who are PROFESSIONAL IN MATLAB i have simulation and i would like to simulate the equation in ,and test the all simulatio

question c

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.