#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Redding
    Posts
    49
    Rep Power
    13

    Complation error "Extra Parameter in call to setiosflags()"


    I continually get this error @ compile time:

    "Extra Parameter in call to setiosflags() in function main()"

    I declare: void setiosflags();

    then: cout << setw(15) << "Wong" << setw(15) << "Harry" << setw(21) << "121 -A Alabama St." << setw(10) << "Lakeville" << setw(15) << " IL" << '\n'
    << setiosflags(ios::left);
    for example.

    Am I making syntactical errors here? New to C++ so that is expected.

    Thank you for any help you can give.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    Yep, when you declare void func() with no parameters, C++ takes it to be implied as void func(void) (Incidentally, C would take it to imply void func(int)). Anyways, that's why the compiler is complaining about it when doing the cout, because it's expecting that the setiosflags() shouldn't take any parameters and you're passing one.

    Incidentally, setiosflags is normally declared as:
    smanip setiosflags ( ios_base::fmtflags mask );

    I'm just curious, but why are you declaring function prototypes for something that is already prototyped in iomanip? Just #include iomanip and you don't have to prototype/declare anything.
    Code:
    #include <iostream>
    #include <iomanip>
    using namespace std;
    
    int main() {
        cout << setw(15) << "Wong" << setw(15) << "Harry" << setw(21) << "121 -A Alabama St." << setw(10) << "Lakeville" << setw(15) << " IL" << '\n'
    << setiosflags(ios::left);
        return 0;
    }
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Redding
    Posts
    49
    Rep Power
    13

    Alright... I see.


    Thanks, fixed it right away.

IMN logo majestic logo threadwatch logo seochat tools logo