   C++ help
  hi,I have few conceptional questions from my beganning C++ class. This is not a take home test or anything like that. These questions are just from a practice provided by the teacher.Which is not a advantage of OOPa) software is more apt to be reusableb) software is more understandable and easier to maintainc) programmers are able to model the real world more closelyd) OOP helps create monolithic programs quicklyWhen designing classes, the operator << and >> cannot be overloaded as members of the class becuase:a) they are not binary operatorsb) the are uranary operatorc) overloaded members must use the same type of both sidesd) they cannot be a friend of the class.   
  I'm hoping you retyped these questions from a worksheet. 'Uranary' operators would more likely be the topic of a biology class rather than a C++ class ;) Seriously, though, rather than have us answer the question, why not tell us your thoughts on them and we'd be happy to respond (well, at least I would, I don't like speaking for everyone else).   ;  I think #1 is c, I'm not sure about number 2 though.   ;Quote:Original post by Anonymous PosterI think #1 is c, I'm not sure about number 2 though.Care to explain your thoughts?   As in, why are a,b, and d advantages and c an advantage (in your opinion)?Graf   ;  but inherentence makes it so we can model real world more so i don't think it's c   ;Quote:Original post by Anonymous PosterI think #1 is cLook up the word monolithic and the answer is obvious [wink]   ;  I will try to explain so u can actually under stand them#1,A: it couldn't be that one cuz classes can be reused in any project and thats the Main point of OOP.#1,B: of course it couldn't be that one cuz if u make a class Name Dog then add a method named Bark god a 3 year old baby could get it.#1,C: same as above without the last part.#1,d: Look Up "monolithic" it means disapproving i thnk thats enouph said.#2,A: TRUE But irrelevant#2,B: TRUE But Also irrelevant#2,c: TRUE They can only be overloaded as friend functions This is the one#2,d: FALSE !Hope u learned some stuff here   ;  #1) d#2 is a very strangely worded question.  << and >> are both binary operators, since they take two operands.  They are NOT unary operators since they take two operands.  Overloaded members do NOT need to use the same type on both sides.  They CAN be a friend of the class.So I'm not sure what answer they are looking for.  All four of those statements are incorrect.  Infact, saying that they cannot be overloaded as members at all is also incorrect.  You can definately overload << and >> as members of a class.If you try to do this for input/output operators you get weird behavior.  When overloading an operator as a member function, the class itself ends up being the left hand operator, and the ostream the right hand.  This leads to the following syntax:object << cout;instead of what you are expecting.  Mind you, this does NOT mean that they can't be overloaded this way, it would just be a strange thing to do.So the short answer is, that you either copied the answers to the second question incorrectly or there is probably a misprint in the practice problems because none of those answers make sense (nor does the question itself).   ;Quote:Original post by Dranith#1) d#2 is a very strangely worded question.  << and >> are both binary operators, since they take two operands.  They are NOT unary operators since they take two operands.  Overloaded members do NOT need to use the same type on both sides.  They CAN be a friend of the class.So I'm not sure what answer they are looking for.  All four of those statements are incorrect.  Infact, saying that they cannot be overloaded as members at all is also incorrect.  You can definately overload << and >> as members of a class.Correct.The intent is, presumably, to ask why you cannot represent operator<<(ostream&, const Object&) as a member of Object; and the reason is that class member operator overloads, for binary operators, are only invoked when the the object instance is on the left-hand side of the operator.Your teacher is apparently confused, and furthermore seems to have a very poor idea of how to teach programming (let alone C++ specifically). This is understandable; hardly anyone has a good idea of it - but standard "memorize the factoid and apply reading comprehension" style multiple choice certainly has nothing to do with it.   ;  its a binary operator but it will only take iostream objects as a left hand side TRY IT error C2248: 'ostream::ostream' : cannot access private member declared in class 'ostream' <<< u r evidence they are binary operators sry i didint read it correctly earlier , so the logical answer would be they cannot be accessd as a member of a class   