Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Question in c++ - urgent (http://www.go4expert.com/forums/question-cpp-urgent-t24846/)

hannach 4Feb2011 17:23

Question in c++ - urgent
 
I have a question in c++

Code:

Read the following code and answer the question bellow:                  void  main(void)
                {
                                CMyStr* pStr = new CMyStr();
                                CMyStr* pStr2 = NULL;
 
                                *pStr = "aba";
                                CMyStr** ppStr = pStr;
 
                                  Print(*ppStr);
 
                                CMyStr sName("Walla");
                                CMyStr sPosition;
 
                                  sPosition = "1";
                                CMyStr sFull = sName +  sPosition;
                                sFull += "2";
 
                                  Print(sFull);
 
                                if(sFull.Length())
                                                Print(sFull[0]);
 
                                *pStr += sFull;
                                Print(*pStr);
                }
  Assume:
        Print(char* msg)  method gets a string pointer and prints it into the screen in a new  line.


Questions:
  a. Write the CMyStr class  that was used here.
          b. What does the program output will be?
          c. Can you  think of problems in the code? If you do, please fix.

Thanks, Hanna

jimblumberg 5Feb2011 00:28

Re: Question in c++ - urgent
 
Quote:

I have a question in c++
I don't see a question, all I see is your assignment. We will not write the code for you.

Where is the code for question a? What do you think the output will be? What problems do you see?

Jim


All times are GMT +5.5. The time now is 03:59.