|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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;
}
|
|
#3
|
|||
|
|||
|
Alright... I see.
Thanks, fixed it right away.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Complation error "Extra Parameter in call to setiosflags()" |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|