Review questions

This is a discussion on Review questions within the C++ Programming forums, part of the General Programming Boards category; Identify all the errors that occur in each of the following statements. Say “no error” if there is no error. ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    13

    Review questions

    Identify all the errors that occur in each of the following statements. Say “no error” if
    there is no error.
    Code:
    (a) vector<int> *vPtr;
    vPtr = new vector<int>(15);
    
    (b) int a[20], b[10];
    b = a;
    
    (c) int *p = {1,4,9};

    Would it be right to say:
    a) No error.
    b) Cannot copy arrays like that. They have to be the same size and values must be copy one at a time with a for loop.
    c) p must point at an array and then dereferenced to output value.

  2. #2
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2,035
    In addition, you can compile it yourself.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code review
    By hamsteroid in forum C Programming
    Replies: 6
    Last Post: 04-04-2007, 12:23 PM
  2. Review a board!
    By Liger86 in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 07-03-2003, 07:43 PM
  3. c++ review
    By san in forum C++ Programming
    Replies: 3
    Last Post: 07-10-2002, 06:56 PM
  4. Can someone review?
    By ob1cnobe in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 09:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21