c++

This is a discussion on c++ within the C++ Programming forums, part of the General Programming Boards category; Why is array of references not allowed??...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    2

    Question c++

    Why is array of references not allowed??

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    Mr. Brainy

    By the way: C++ is not a good title.

    A) try an array of pointers instead. A reference is a specific form of a pointer for a sepcific purpose.

    B) That specific purpose is so you can pass the ADDRESS of an array to a function. you can't pass the array itself. You increment the pointer by one to get the next element. So really, I can't see a point in having an array of references anyway,

    Sean Mackrory
    sean_mackrory@hotmail.com

  3. #3
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    Array of referances is allowed.

    int& A[4];

  4. #4
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    No they're not, even though it would be possible they were disallowed due to the inconsistancies they'd create (sizeof array elements and you can't have a pointer to a reference).
    zen

Popular pages Recent additions subscribe to a feed

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