Question in c++ - urgent

Discussion in 'C++' started by hannach, Feb 4, 2011.

  1. hannach

    hannach New Member

    Joined:
    Feb 4, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I have a question in c++

    Code:
    [SIZE=2]Read the following code and answer the question bellow:[/SIZE]  [SIZE=2]                void  main(void)[/SIZE]
    [SIZE=2]                {[/SIZE]
    [SIZE=2]                                 CMyStr* pStr = new CMyStr();[/SIZE]
    [SIZE=2]                                 CMyStr* pStr2 = NULL;[/SIZE]
     
    [SIZE=2]                                 *pStr = "aba";[/SIZE]
    [SIZE=2]                                CMyStr** ppStr = pStr;[/SIZE]
     
      [SIZE=2]                                 Print(*ppStr);[/SIZE]
     
    [SIZE=2]                                 CMyStr sName("Walla");[/SIZE]
    [SIZE=2]                                CMyStr sPosition;[/SIZE]
     
      [SIZE=2]                                 sPosition = "1";[/SIZE]
    [SIZE=2]                                CMyStr sFull = sName +  sPosition;[/SIZE]
    [SIZE=2]                                sFull += "2";[/SIZE]
     
      [SIZE=2]                                 Print(sFull);[/SIZE]
     
    [SIZE=2]                                 if(sFull.Length())[/SIZE]
    [SIZE=2]                                                 Print(sFull[0]);[/SIZE]
     
    [SIZE=2]                                 *pStr += sFull;[/SIZE]
    [SIZE=2]                                Print(*pStr);[/SIZE]
    [SIZE=2]                }[/SIZE]
      [SIZE=2]Assume: [/SIZE]
    [SIZE=2]        Print(char* msg)  method gets a string pointer and prints it into the screen in a new  line.[/SIZE]
    [SIZE=2]
    [/SIZE]
    [SIZE=2]Questions:[/SIZE]
    [SIZE=2]  a. Write the CMyStr class  that was used here.[/SIZE]
    [SIZE=2]          b. What does the program output will be?[/SIZE]
    [SIZE=2]          c. Can you  think of problems in the code? If you do, please fix.[/SIZE]
    
    Thanks, Hanna
     
  2. jimblumberg

    jimblumberg New Member

    Joined:
    May 30, 2010
    Messages:
    120
    Likes Received:
    29
    Trophy Points:
    0
    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice