Thread: Functions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    12

    Functions

    from the function tutorial on this site, I understand how they work but what I dont get is the placement of it, for example
    Code:
    #include <iostream>
    int mult(int x, int y) {return x*y;}
    int main()
    {
        int x,y;
        std::cin>>x>>y;
        std::cout<<mult(x,y)<<std::endl;
        system("PAUSE");
        return 0;
    }
    In the example on the tutorial it had return at the end but that's for making blueprints of a program so I put it with the mult function before main() and it worked but I tried sticking main in front of the mult function and the program no longer works and im getting errors such as a parse error before int on the 3rd line, but why?
    Last edited by LegendsEnd; 04-18-2004 at 05:26 PM.
    Rawr.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM