>" matches these operands"/> cin >> std::min -->No operator ">>" matches these operands
niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » SGI/IRIX
cin >> std::min -->No operator ">>" matches these operands
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
Author Message
David Anderson
*nix forums beginner


Joined: 09 Apr 2005
Posts: 17

PostPosted: Tue Mar 01, 2005 4:45 pm    Post subject: Re: cin >> std::min -->No operator ">>" matches these operands Reply with quote

In article <1109694810.808038.30920@l41g2000cwc.googlegroups.com>,
<clusardi2k@aol.com> wrote:
Quote:
Your version of the posted program is a little different than mine. I
feel you've been misled!
[..]


Not mislead. But I did rewrite the example, as I did not
think the original correct (but what do I know).

Quote:
The reason I want to use identical code on both platforms is I have a
lot of I/O and I don't want 2 versions of the same code.

Good motivation :-)

[..]
Quote:
On Linux, I went to "cout << std::hex << minx;" because that works,
and on SGI "cout << hex << minx;" works. I want to find out how
to use the Linux format on both computers.

Your version of the code seem to be dependent on "setf" for output
format!

Yes, well, see below, I was missing something in Josuttis "C++ Standard
Library".

Quote:
Also, to answer your questions:

%CC -v
MIPSpro Compilers: Version 7.4.2m

Good. Thanks.


Quote:
When I compile the your version of the program, I get the following
errors:

The namespace "std" has no member "cin".

The namespace "std" has no member "cout".

The namespace "std" has no member "endl".

Using 7.4.4 (unreleased) on my version, no errors.

Quote:
--------------------------------------------------------------

I don't think it makes much sense to mix the .h and non-.h
header files! If you are going to write standard C++ use
the new form.

Quote:
#include <ios
#include <iostream.h

int main ()
{
int minx;
cout << "hour " << std::hex << 10 << endl; // or 0xc

std::cout << "Enter minute "";

The above line is malformed, "" at end. Not compilable at all.
Mixing cout and std::cout is strange.

Quote:
cin >> std::hex >> minx;
}

I could not find the short form in Josuttis yesterday
so used setf form. Today I find it on page 622, same page
as setf use. Sigh.

Here is a version that seems to work with 7.4.4 and demonstrates
that cin and std::hex works sensibly.


goalie 30% ./a.out
hour a
Enter minute 22
34
goalie 31% cat stdmin2.cxx

#include <ios>
#include <iostream>

int main ()
{
int minx;
std::cout << "hour " << std::hex << 10 << std::endl; // or 0xc

std::cout << "Enter minute ";

std::cin >> std::hex >> minx;
// Now show we read in in hex
std::cout <<std::dec << minx << std::endl;
}


Mixing header forms (.h and non-.h) makes me very nervous as
SGI std-header-writers use the form as a clue whether to introduce
the std:: namespace.

All your environments *should* have non-.h for ios and iostream.

Hope this helps.
David B. Anderson davea at sgi dot com http://reality.sgiweb.org/davea
Back to top
clusardi2k@aol.com
*nix forums beginner


Joined: 19 Jul 2005
Posts: 40

PostPosted: Tue Mar 01, 2005 3:51 pm    Post subject: Re: cin >> std::min -->No operator ">>" matches these operands Reply with quote

Your version of the posted program is a little different than mine. I
feel you've been misled!

On SGI and Linux, I want to do something like

cin >> std::hex >> minx;

and

cout << "Min is " << std::hex << minx << endl;

The reason I want to use identical code on both platforms is I have a
lot of I/O and I don't want two versions of the same code.

IE: I don't want to use the following ugly style of coding:

#ifdef __sgi
cin ..
#else
cin ..
#endif

On Linux, I went to "cout << std::hex << minx;" because that works,
and on SGI "cout << hex << minx;" works. I want to find out how
to use the Linux format on both computers.

Your version of the code seem to be dependent on "setf" for output
format!

Also, to answer your questions:

%CC -v
MIPSpro Compilers: Version 7.4.2m

When I compile the "your" version of the program, I get the following
errors:

The namespace "std" has no member "cin".

The namespace "std" has no member "cout".

The namespace "std" has no member "endl".

My version of the code (below)
Christopher Lusardi
--------------------------------------------------------------
#include <ios>
#include <iostream.h>

int main ()
{
int minx;
cout << "hour " << std::hex << 10 << endl; // or 0xc

std::cout << "Enter minute ";

cin >> std::hex >> minx;
}

%CC file.cpp

No operator ">>" matches these operands.
the operand types are: istream_withassign >> <unknown type>.

cin >> std::min;
^
Back to top
clusardi2k@aol.com
*nix forums beginner


Joined: 19 Jul 2005
Posts: 40

PostPosted: Tue Mar 01, 2005 3:33 pm    Post subject: Re: cin >> std::min -->No operator ">>" matches these operands Reply with quote

Your version of the posted program is a little different than mine. I
feel you've been misled!

On SGI and Linux, I want to do something like

cin >> std::hex >> minx;

and

cout << "Min is " << std::hex << minx << endl;

The reason I want to use identical code on both platforms is I have a
lot of I/O and I don't want 2 versions of the same code.

IE: I don't want to use the style of coding:

#ifdef __sgi
cin ..
#else
cin ..
#endif

On Linux, I went to "cout << std::hex << minx;" because that works,
and on SGI "cout << hex << minx;" works. I want to find out how
to use the Linux format on both computers.

Your version of the code seem to be dependent on "setf" for output
format!

Also, to answer your questions:

%CC -v
MIPSpro Compilers: Version 7.4.2m

When I compile the your version of the program, I get the following
errors:

The namespace "std" has no member "cin".

The namespace "std" has no member "cout".

The namespace "std" has no member "endl".

Christopher Lusardi
--------------------------------------------------------------
#include <ios>
#include <iostream.h>

int main ()
{
int minx;
cout << "hour " << std::hex << 10 << endl; // or 0xc

std::cout << "Enter minute "";

cin >> std::hex >> minx;
}
Back to top
David Anderson
*nix forums beginner


Joined: 09 Apr 2005
Posts: 17

PostPosted: Mon Feb 28, 2005 6:29 pm    Post subject: Re: cin >> std::min -->No operator ">>" matches these operands Reply with quote

In article <1109615101.342186.301160@g14g2000cwa.googlegroups.com>,
<clusardi2k@aol.com> wrote:
Quote:
For portability reasons, how can I compile the below code on SGI?

#include <ios
#include <iostream.h

int main ()
{
int min;
cout << "hour " << std::hex << c << endl;

cout << "Enter min "";

cin >> std::hex >> min;
}
Mixing <ios> and <iostream.h> is confusing things.

(the std namespace vs no std namespace)

The variable 'c' above does not exist.
The variable name 'min' in some contexts might conflict with
a standard function.

//Revised function, reads in in hex, outputs in decimal:
#include <ios>
#include <iostream>

int main ()
{
int minx;

std::cout << "Enter min ";

std::cin.setf(std::ios_base::hex,std::ios_base::basefield);
std::cin >> minx;
//cin >> std::hex >> minx;
std::cout << minx << std::endl;
}

You don't mention what IRIX compiler release you use either.
I tried the above on latest.

Regards,
David B. Anderson davea at sgi dot com http://reality.sgiweb.org/davea
Back to top
clusardi2k@aol.com
*nix forums beginner


Joined: 19 Jul 2005
Posts: 40

PostPosted: Mon Feb 28, 2005 5:39 pm    Post subject: Re: cin >> std::min -->No operator ">>" matches these operands Reply with quote

clusard...@aol.com wrote:
Quote:

CC file.cpp
No operator ">>" matches these operands.
the operand types are: istream_withassign >> <unknown type>.

cin >> std::min;
^


Sorry, I forgot to add that for readability I want to use:
std::min!

Thank you,
Christopher Lusardi
Back to top
clusardi2k@aol.com
*nix forums beginner


Joined: 19 Jul 2005
Posts: 40

PostPosted: Mon Feb 28, 2005 5:39 pm    Post subject: Re: cin >> std::min -->No operator ">>" matches these operands Reply with quote

clusard...@aol.com wrote:
Quote:

CC file.cpp
No operator ">>" matches these operands.
the operand types are: istream_withassign >> <unknown type>.

cin >> std::min;
^


Sorry, I forgot to add that for readability I want to use:
std::min!

Thank you,
Christopher Lusardi
Back to top
clusardi2k@aol.com
*nix forums beginner


Joined: 19 Jul 2005
Posts: 40

PostPosted: Mon Feb 28, 2005 5:25 pm    Post subject: cin >> std::min -->No operator ">>" matches these operands Reply with quote

For portability reasons, how can I compile the below code on SGI?

#include <ios>
#include <iostream.h>

int main ()
{
int min;
cout << "hour " << std::hex << c << endl;

cout << "Enter min "";

cin >> std::hex >> min;
}

CC file.cpp
No operator ">>" matches these operands.
the operand types are: istream_withassign >> <unknown type>.

cin >> std::min;
^

Thank you,
Christopher Lusardi
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 1:37 am | All times are GMT
navigation Forum index » *nix » SGI/IRIX
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts regular expression - matches codecraig python 2 Fri Jul 21, 2006 1:36 pm
No new posts Understanding the bitwise AND operator zirconx@gmail.com C++ 17 Tue Jul 18, 2006 9:58 pm
No new posts ambiguous operator>>(char&) Zorro C++ 2 Tue Jul 18, 2006 9:18 am
No new posts Doubt on new operator edu.mvk C++ 6 Mon Jul 17, 2006 12:06 pm
No new posts error: invalid operands to binary & muthu C 4 Mon Jul 17, 2006 9:41 am

Mobile Phones | Loans | Xbox Mod Chips | Mobile Phone | Credit Cards
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1809s ][ Queries: 20 (0.0771s) ][ GZIP on - Debug on ]