Operator Overlaoding Problems using M$ VC++ 6.0 SP1 
Author Message
 Operator Overlaoding Problems using M$ VC++ 6.0 SP1

Greetings,

I have the following code that successfully compiles under 5.0 SP3, but
fails to work under 6.0 SP1:

class JIF_Pdu_Test
{
public:

  <snipped>

  friend istream& operator >> (istream& is, JIF_Pdu_Test& test);

Quote:
};

istream& operator >> (istream& is, JIF_Pdu_Test& test)
{

  <snipped>

  return is;

Quote:
}

However, I get the following error:

error C2679: binary '>>' : no operator defined which takes a right-hand
operand of type 'class JIF_Pdu_Test' (or there is no acceptable
conversion)

Suggestions appreciated, since I have failed to find anything on MSDN or
via Dejanews that fits the bill.

Thanks,
Steve



Mon, 23 Apr 2001 03:00:00 GMT  
 Operator Overlaoding Problems using M$ VC++ 6.0 SP1

Quote:

>Greetings,

>I have the following code that successfully compiles under 5.0 SP3, but
>fails to work under 6.0 SP1:

>class JIF_Pdu_Test
>{
>public:

>  <snipped>

>  friend istream& operator >> (istream& is, JIF_Pdu_Test& test);

>};

>istream& operator >> (istream& is, JIF_Pdu_Test& test)
>{

>  <snipped>

>  return is;
>}

>However, I get the following error:

>error C2679: binary '>>' : no operator defined which takes a right-hand
>operand of type 'class JIF_Pdu_Test' (or there is no acceptable
>conversion)

>Suggestions appreciated, since I have failed to find anything on MSDN or
>via Dejanews that fits the bill.

For some strange reason, VC6 requires that the friend
be declared prior to the friendship grant.  This is a known
bug which shows up in the Microsoft [sic] Knowledge Base.

--Larry Brasfield
Above opinions may be mine alone.



Mon, 23 Apr 2001 03:00:00 GMT  
 Operator Overlaoding Problems using M$ VC++ 6.0 SP1
Hi,

I would suspect a missing using-declaration or a using directive.

Danny

Quote:

> Greetings,

> I have the following code that successfully compiles under 5.0 SP3, but
> fails to work under 6.0 SP1:

> class JIF_Pdu_Test
> {
> public:

>   <snipped>

>   friend istream& operator >> (istream& is, JIF_Pdu_Test& test);

> };

> istream& operator >> (istream& is, JIF_Pdu_Test& test)
> {

>   <snipped>

>   return is;
> }

> However, I get the following error:

> error C2679: binary '>>' : no operator defined which takes a right-hand
> operand of type 'class JIF_Pdu_Test' (or there is no acceptable
> conversion)

> Suggestions appreciated, since I have failed to find anything on MSDN or
> via Dejanews that fits the bill.

> Thanks,
> Steve



Sun, 06 May 2001 03:00:00 GMT  
 Operator Overlaoding Problems using M$ VC++ 6.0 SP1
I found the same problem and found many other people too. All the messages I
found on other news group indicate that this is bug from the compiler related
to namespace.
I am eargerly waitoing for the fix since no program in my company would work
with this version of VC++ 6 sp1.

Here is my sample code that also reproduce the problem

#include <iostream>
using namespace std;

ostream& operator << (ostream& os, const int& ) { return os; }

class A
{
public:
 friend ostream& operator << (ostream& os, const A& a);
 ostream& print( ostream& os ) { return os << *this; }

Quote:
};

> Hi,

> I would suspect a missing using-declaration or a using directive.

> Danny


> > Greetings,

> > I have the following code that successfully compiles under 5.0 SP3, but
> > fails to work under 6.0 SP1:

> > class JIF_Pdu_Test
> > {
> > public:

> >   <snipped>

> >   friend istream& operator >> (istream& is, JIF_Pdu_Test& test);

> > };

> > istream& operator >> (istream& is, JIF_Pdu_Test& test)
> > {

> >   <snipped>

> >   return is;
> > }

> > However, I get the following error:

> > error C2679: binary '>>' : no operator defined which takes a right-hand
> > operand of type 'class JIF_Pdu_Test' (or there is no acceptable
> > conversion)

> > Suggestions appreciated, since I have failed to find anything on MSDN or
> > via Dejanews that fits the bill.

> > Thanks,
> > Steve



Sat, 12 May 2001 03:00:00 GMT  
 Operator Overlaoding Problems using M$ VC++ 6.0 SP1
I found the same problem and found many other people too. All the messages I
found on other news group indicate that this is bug from the compiler related
to namespace.
I am eargerly waitoing for the fix since no program in my company would work
with this version of VC++ 6 sp1.

Here is my sample code that also reproduce the problem

#include <iostream>
using namespace std;

ostream& operator << (ostream& os, const int& ) { return os; }

class A
{
public:
 friend ostream& operator << (ostream& os, const A& a);
 ostream& print( ostream& os ) { return os << *this; }

Quote:
};

> Hi,

> I would suspect a missing using-declaration or a using directive.

> Danny


> > Greetings,

> > I have the following code that successfully compiles under 5.0 SP3, but
> > fails to work under 6.0 SP1:

> > class JIF_Pdu_Test
> > {
> > public:

> >   <snipped>

> >   friend istream& operator >> (istream& is, JIF_Pdu_Test& test);

> > };

> > istream& operator >> (istream& is, JIF_Pdu_Test& test)
> > {

> >   <snipped>

> >   return is;
> > }

> > However, I get the following error:

> > error C2679: binary '>>' : no operator defined which takes a right-hand
> > operand of type 'class JIF_Pdu_Test' (or there is no acceptable
> > conversion)

> > Suggestions appreciated, since I have failed to find anything on MSDN or
> > via Dejanews that fits the bill.

> > Thanks,
> > Steve



Sat, 12 May 2001 03:00:00 GMT  
 Operator Overlaoding Problems using M$ VC++ 6.0 SP1
Quote:

> I found the same problem and found many other people too. All the messages I
> found on other news group indicate that this is bug from the compiler related
> to namespace.
> I am eargerly waitoing for the fix since no program in my company would work
> with this version of VC++ 6 sp1.

> Here is my sample code that also reproduce the problem

> #include <iostream>
> using namespace std;

> ostream& operator << (ostream& os, const int& ) { return os; }

> class A
> {
> public:
>  friend ostream& operator << (ostream& os, const A& a);
>  ostream& print( ostream& os ) { return os << *this; }
> };

I seem to recall that you have to forward declare A and the operator
first. Have you tried this?

#include <iostream>
using namespace std;

// what's this one doing here?
// ostream& operator << (ostream& os, const int& ) { return os; }

// forward declarations
class A;
ostream &operator<<(ostream &, const A &);
// now MSVC++ knows the function exists, and recognizes it

class A
{
public:
   friend ostream& operator << (ostream& os, const A& a);
   ostream& print( ostream& os ) { return os << *this; }

Quote:
};

--
Martin Fabian                         http://www.s2.chalmers.se/~fabian/
                                                                      --
"Say hello to my little friend."                          (Tony Montana)
"Ka-Boom!"                                           (his little friend)

        /* Remove NOSPAM from reply-to address to mail me */



Tue, 15 May 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. MS Visual Studio 6.0 and Windows XP SP1

2. Using VC++ 6.0 as an automation client to view and print reports from MS Access 97

3. Custom Build Using MS 6.0 VC++

4. Error in VC 6.0 SP1 Compiler?

5. VC++ 6.0 SP1 ??

6. Error in VC 6.0 SP1 Compiler?

7. Problem to convert from VC 6.0 to VC 7.1 because of using filebuf::setmode()

8. Crash using MS ADO Data Control/MS DataGrid 6.0

9. Memory Read/write problem using vc++ 6.0

10. Memory Read/write problem using vc++ 6.0

11. Problem with MS VC++ 6.0 SP5: libcd.pdb

12. MS VC ver 6.0 dynamicly linked mfc libs problem

 

 
Powered by phpBB® Forum Software