Tuesday, July 14, 2009

Write a C++ program to?

Write the following Class declaration for an abstract data type called word which will store a string. Include the following member functions in the class declaration.


·Viod store_word(char*cstr), which adds the incoming string to the existing contents of word.


·Void display_word(void) which display the contents of word on standards output


·Word(char*cstr=null) the default argument constructor


·~word(void) the destruction.

Write a C++ program to?
to append (add in the end) string use:


ResultString = String1 + String2





to display word in standard output, you have to declare that you're using an output. If it is a console:





write this preprocessor code in the topmost of the code:


#include %26lt;iostream%26gt;





Then use this function:


cout %26lt;%26lt; String;





this class you're creating, I tell you, is completely useless, since these string operation you request is simply one-liner easy to understand code.





What would you prefer:





strHello = "abc" + "def";





Or





append("def");





I prefer the first, because of readability, performance, easily understood, and avoid misunderstanding
Reply:try #include%26lt;iostream.h%26gt; cause t is a char function..


No comments:

Post a Comment