473,395 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

i am getting errors in C++

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
6 2646
Banfa
9,065 Expert Mod 8TB
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
srikar
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
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
srikar
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
9,065 Expert Mod 8TB
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
srikar
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

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

Similar topics

11
by: mikey_boy | last post by:
Hello! Curious if anyone could give me a hand. I wrote this PHP script with makes a simple connection to a mysql database called firstdb and just pulls back the results and displays on the...
9
by: JeffFinnan | last post by:
I can get a source file to write html code fully in Iexplorer. However, in Netscape 4.8, I cannot get it to write this particular line: <SCRIPT LANGUAGE="JavaScript" SRC="src1.js"></script> in the...
2
by: iainw | last post by:
HI All, 1st post here, i wonder if you can help. We are about to upload CMS t a windows server and keep getting 2 errors below. We need to go LIVE an it's delaying us. An error occured when...
4
by: Pat | last post by:
In my Web.config i have :- <customErrors mode="On" defaultRedirect="genericerror.htm"> <error statusCode="404" redirect="pagenotfound.aspx"/> </customErrors to get page not found error but...
2
by: maxkumar | last post by:
Hi, I am running a ASP.NET 1.1 site on Win Server 2003 with IIS 6.0. The website has been running for about 1.5 years now. In the past, we used to have random cases of session variables getting...
6
by: David Lozzi | last post by:
Hello there, I'm getting the following error System.NullReferenceException: Object reference not set to an instance of an object. at shopping_bag.GetBagTotals()
2
by: Manikandan | last post by:
Hi, I have a program written in .Net Framework 1.1 using Visual studio enterprise edition 2003. I tried compiling the same program in visual c# express edition 2005. I'm getting following...
8
by: illuzion | last post by:
ok I keep getting this error: Parse error: syntax error, unexpected T_VARIABLE in /home/illuzion/public_html/BAMF/contactus.php on line 38 and this error is possibly on other lines could...
5
by: tshad | last post by:
I have the following class in my VS 2008 project that has a namespace of MyFunctions. ********************************* Imports System Imports System.Text.RegularExpressions Namespace...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.