error with code

This is a discussion on error with code within the C++ Programming forums, part of the General Programming Boards category; function prototype: void BubbleSort( int &inArray, int &nsize); calling from main BubbleSort (arr, size); error C2664: 'BubbleSort' : cannot convert ...

  1. #1
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294

    error with code

    function prototype: void BubbleSort( int &inArray, int &nsize);

    calling from main

    BubbleSort (arr, size);
    error C2664: 'BubbleSort' : cannot convert parameter 1 from 'int [5]' to 'int &'
    Games Reviews Previews Desktop Themes Downloads Paintball Forums Shareware Freeware and much more

    The best in Technology and Gaming News

    www.back2games.com

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    Maybe...
    Code:
    void BubbleSort( int *inArray, int &nsize);
    Instead of...
    Code:
    void BubbleSort( int &inArray, int &nsize);
    As both prototype and where you actually define the function.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Arrays are automatically passed by reference, so don't use either the * or & operator in your function prototype.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

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