Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Operator not found for the type

Reply
Thread Tools

Operator not found for the type

 
 
Ian Collins
Guest
Posts: n/a
 
      03-01-2007
The Cool Giraffe wrote:
> I tried to define an overloader for the operator <<. My source
>
> code is great except the stupid compiler doesn't get it.
>
>
>
> std:stream& Particle:perator<< (Particle& part) {
>
> std:stream* ost = NULL;
>
> (*ost) << "diffusion particle";
>
> return (*ost); }
>
>
> The error message is
> error C2679: binary '<<' : no operator found which takes a right-hand
> operand of type 'Particle' (or there is no acceptable conversion)
> What did i do unsmartly?
>

Don't make the operator a member function, use

std:stream& operator<<( std:stream&, const Particle& ) {..}

--
Ian Collins.
 
Reply With Quote
 
 
 
 
The Cool Giraffe
Guest
Posts: n/a
 
      03-01-2007
I tried to define an overloader for the operator <<. My source

code is great except the stupid compiler doesn't get it.



std:stream& Particle:perator<< (Particle& part) {

std:stream* ost = NULL;

(*ost) << "diffusion particle";

return (*ost); }


The error message is
error C2679: binary '<<' : no operator found which takes a right-hand
operand of type 'Particle' (or there is no acceptable conversion)
What did i do unsmartly?

--
Vänligen Kerstin Viltersten
(The Cool Giraffe)


 
Reply With Quote
 
 
 
 
Ron Natalie
Guest
Posts: n/a
 
      03-01-2007
Ian Collins wrote:
> The Cool Giraffe wrote:
>> I tried to define an overloader for the operator <<. My source
>>
>> code is great except the stupid compiler doesn't get it.
>>
>>
>>
>> std:stream& Particle:perator<< (Particle& part) {
>>
>> std:stream* ost = NULL;
>>
>> (*ost) << "diffusion particle";
>>
>> return (*ost); }
>>
>>
>> The error message is
>> error C2679: binary '<<' : no operator found which takes a right-hand
>> operand of type 'Particle' (or there is no acceptable conversion)
>> What did i do unsmartly?
>>

> Don't make the operator a member function, use
>
> std:stream& operator<<( std:stream&, const Particle& ) {..}
>

It's not the source of the compile error, but he also is dereferencing
a null pointer for unexplained reasons.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is a "convert to any type" operator overkill and dangerous? template<typename T> operator T () Qi C++ 2 07-01-2011 03:39 AM
C extension type gives type error in power operator Paul Moore Python 2 11-20-2008 03:57 PM
std::operator<<(basic_ostream&, type) vs. std::basic_ostream::operator(type)... ? Martin T. C++ 7 03-10-2008 10:42 AM
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) aarthi28@gmail.com C++ 29 06-21-2007 08:42 PM
Operator is not valid for type 'DBNull' and type 'Date' ASP .Net 7 06-09-2004 03:36 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57