c++ compile errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anon Emous
    New Member
    • Dec 2011
    • 1

    c++ compile errors

    With the following block of code, I get the error message "Expected initializer before 'void'.

    #include <iostream>

    void Add( int add1, int add2)
    void Sub( int sub1, int sub2)
    void Mlt( int mlt1, int mlt2)
    void Div( int div1, div2)

    but I only get the error in the line declaring the Sub function. HELP!
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You are missing semi-colons at the ends of the statements.

    Comment

    • Mubasher Aslam
      New Member
      • Dec 2011
      • 1

      #3
      YOU are missing the using namespace std; statement if you work in visual c++ .

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        using namespace std; is part of C++ and has nothing to do with using Visual C++. Plus, the code posted would not require this statement.

        Comment

        • CodeJock21
          New Member
          • Jan 2012
          • 1

          #5
          Code:
          void Add( int add1, int add2)
          void Sub( int sub1, int sub2)
          void Mlt( int mlt1, int mlt2)
          void Div( int div1, div2) <---  int div2
          You are missing
          Code:
          int div2
          in
          Code:
          void Div( int div1, div2)

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            Did you read my post #2?

            Comment

            • lspxy
              New Member
              • Nov 2011
              • 12

              #7
              Code:
              #include <iostream>
              using namespace std;
              
              void Add( int add1, int add2);
              void Sub( int sub1, int sub2);
              void Mlt( int mlt1, int mlt2);
              void Div( int div1, int div2);

              Comment

              Working...