Void call by reference function

This is a discussion on Void call by reference function within the C++ Programming forums, part of the General Programming Boards category; Here is my code: #include <iostream.h> using std::cout; using std::cin; using std::endl; void triplecallbyreference( int & ); int main() { ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    34

    Void call by reference function

    Here is my code:

    #include <iostream.h>

    using std::cout;
    using std::cin;
    using std::endl;

    void triplecallbyreference( int & );

    int main()
    {

    int num1;

    cout << "Enter the number to cube: ";
    cin >> num1;
    cout << num1<< " cubed is ";
    triplecallbyreference( num1);
    cout << endl;
    return 0;
    }

    void power( int &num2 )
    {
    num2 = num2 * num2 * num2;
    }


    Now here are my errors when I go to compile:
    /usr/bin/ld:
    Unresolved:
    triplecallbyreference(int &)
    collect2: ld returned 1 exit status


    Can someone tell me 1) what does this error mean, and 2) what am I doing wrong in my code?

    Thank you! The Ski
    http://members.ebay.com/aboutme/the_ski/

  2. #2
    Unregistered
    Guest
    the function prototype, function call, and function definition all need to use the same name. The name in the function definition is different from the other two, hence the error.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    34
    Thank you! It helps if when I go through my notes that I use the right notes that are for the program that I am working on rather then the previous one.
    http://members.ebay.com/aboutme/the_ski/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM
  3. Possible Loss of data
    By silicon in forum C Programming
    Replies: 3
    Last Post: 03-24-2004, 12:25 PM
  4. passing counters between function
    By BungleSpice in forum C Programming
    Replies: 18
    Last Post: 02-21-2004, 06:16 PM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM

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