By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,871 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,871 IT Pros & Developers. It's quick & easy.

i am getting errors in C++

P: 62
When the below function was run on linux64 bit machine in C++
i am getting the following problems.

void real_rec::dump(ostream& s, const int indent ) const
{

s << "real = ";
long f = cout.flags();
s.setf( ios::fixed );
s.precision( 2 );
s << value << "\n";
s.flags(f);

}
when i am using this function in my code i am getting this type of errors, when this function was ran on 16 bit machine I didnt had any problem

the corresponding errors are
common.cxx:1079: no matching function for call to `std::basic_ostream<char,
std::char_traits<char> >::flags(long int&)'
/usr/include/c++/3.2.3/bits/ios_base.h:333: candidates are: std::_Ios_Fmtflags
std::ios_base::flags() const
/usr/include/c++/3.2.3/bits/ios_base.h:337: std::_Ios_Fmtflags
std::ios_base::flags(std::_Ios_Fmtflags)

Please helpme to resolve this problem.
Sep 20 '06 #1
Share this Question
Share on Google+
6 Replies


Banfa
Expert Mod 5K+
P: 8,916
common.cxx:1079: no matching function for call to `std::basic_ostream<char,
std::char_traits<char> >::flags(long int&)'

This error refers to the line s.flags(f); the function prototype given is what would be require to make this call. flags() does not have this prototype it has the prototypes given in the following 2 messages.

/usr/include/c++/3.2.3/bits/ios_base.h:333: candidates are: std::_Ios_Fmtflags
std::ios_base::flags() const

/usr/include/c++/3.2.3/bits/ios_base.h:337: std::_Ios_Fmtflags
std::ios_base::flags(std::_Ios_Fmtflags)


The problem is that you have declared f as

long f;

when it should be

std::_Ios_Fmtflags f;

or according to my documentation

ios_base::fmtflags f;

within namespace std
Sep 20 '06 #2

P: 62
common.cxx:1079: no matching function for call to `std::basic_ostream<char,
std::char_traits<char> >::flags(long int&)'

This error refers to the line s.flags(f); the function prototype given is what would be require to make this call. flags() does not have this prototype it has the prototypes given in the following 2 messages.

/usr/include/c++/3.2.3/bits/ios_base.h:333: candidates are: std::_Ios_Fmtflags
std::ios_base::flags() const

/usr/include/c++/3.2.3/bits/ios_base.h:337: std::_Ios_Fmtflags
std::ios_base::flags(std::_Ios_Fmtflags)


The problem is that you have declared f as

long f;

when it should be

std::_Ios_Fmtflags f;

or according to my documentation

ios_base::fmtflags f;

within namespace std
Thank you Banfa my problem got solved by declaring f as std::_Ios_Fmtflags

Banfa I didnot understand some questions like

1) What does s.flags(f) function represent, what is the need of this function?

2) what is the use of the flags std::_Ios_Fmtflags and std::Ios_base ::flags

what does this flags represent,

3) What is the relation of these flags with basic io streams.

banfa help me to resolve my queries.

Once again Thank you banfa for your replies to my queries.
Sep 21 '06 #3

P: 2
When the below function was run on linux64 bit machine in C++
i am getting the following problems.

void real_rec::dump(ostream& s, const int indent ) const
{

s << "real = ";
long f = cout.flags();
s.setf( ios::fixed );
s.precision( 2 );
s << value << "\n";
s.flags(f);

}
when i am using this function in my code i am getting this type of errors, when this function was ran on 16 bit machine I didnt had any problem

the corresponding errors are
common.cxx:1079: no matching function for call to `std::basic_ostream<char,
std::char_traits<char> >::flags(long int&)'
/usr/include/c++/3.2.3/bits/ios_base.h:333: candidates are: std::_Ios_Fmtflags
std::ios_base::flags() const
/usr/include/c++/3.2.3/bits/ios_base.h:337: std::_Ios_Fmtflags
std::ios_base::flags(std::_Ios_Fmtflags)

Please helpme to resolve this problem.
try defining f as follows:

std::ios::fmtflags f = cout.flags();

This should fix your compile problem
Sep 21 '06 #4

P: 62
Thanks 4 d reply, I got resolved my problem,

But I didnt clear the above mentioned questions.

Can u explain me
Sep 21 '06 #5

Banfa
Expert Mod 5K+
P: 8,916
1) What does s.flags(f) function represent, what is the need of this function?

2) what is the use of the flags std::_Ios_Fmtflags and std::Ios_base ::flags

what does this flags represent,

3) What is the relation of these flags with basic io streams.
1. It allows you to set and retrieve the format flags for the stream, you code appears to be copying format flags from 1 stream to another.

2. This is very common, they are actually types. Many classes (particularly the standard ones) typedef there own variables std::Ios_base::flags is the type used to store the format flags and is used as the parameter type and return type for the function flags()

3. These flags hold the formating to be used when inputing or outputing data, for instance fixed precision or fixed width
Sep 21 '06 #6

P: 62
1. It allows you to set and retrieve the format flags for the stream, you code appears to be copying format flags from 1 stream to another.

2. This is very common, they are actually types. Many classes (particularly the standard ones) typedef there own variables std::Ios_base::flags is the type used to store the format flags and is used as the parameter type and return type for the function flags()

3. These flags hold the formating to be used when inputing or outputing data, for instance fixed precision or fixed width
Hi Banfa Thank u much,

I am happy for the fast reply, I got understood the probelm.

regards

srikar
Sep 21 '06 #7

Post your reply

Sign in to post your reply or Sign up for a free account.