Don Hedgpeth wrote:[color=blue]
> Here's a question - I'm new to c++ and I have two classes that overload the >> operator. One class calls the other...such as.
>
> //code for class1
> friend std::istream& operator >> (std::istream& lhs, class1& rhs) {
> ....random code here
> return lhs:}[/color]
This makes no sense the way you've defined it. If it's a friend, then
it's not a member function of the class, but you appear to be defining
it right there. (And of course, if it were a member function, then you
wouldn't include class1& as a parameter). Take a look at the FAQ for
an example of doing it correctly:
http://www.parashift.com/c++-faq-lit...html#faq-15.10
[color=blue]
>
> //code for class2
> private:
> class1 jimbo;
> friend std::istream& operator >> (std::istream& lhs, class2& rhs) {
> lhs>>rhs.jimbo;
> return lhs;}[/color]
Same problem here.
[color=blue]
> This code gives me a compile error and I just cannot seem to figure it
> out. I know that the line lhs>>rhs.jimbo; is incorrect, but I am clueless
> as to why? Any hints?[/color]
See above.
Best regards,
Tom