448,799 Members | 1,376 Online
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

# using T& operator*(T*);

 P: n/a Hi, How do i use this definition of overloaded operator, T& operator*(T*); like struct X {}; X ox; X* px=&ox; X oy; oy=*px; is this correct use of this operator overload. Help SS Jul 23 '05 #1
6 Replies

 P: n/a "sandSpiderX" wrote in message news:11**********************@g43g2000cwa.googlegr oups.com Hi, How do i use this definition of overloaded operator, T& operator*(T*); like struct X {}; X ox; X* px=&ox; X oy; oy=*px; is this correct use of this operator overload. No, it is not even close. You can't guess this stuff, but it is explained in any number of textbooks. You should be working through one. -- John Carson Jul 23 '05 #2

 P: n/a Can I see some code now Some example of this .... Jul 23 '05 #3

 P: n/a "sandSpiderX" wrote in message news:11*********************@g14g2000cwa.googlegro ups.com Can I see some code now Some example of this .... Here is a free 2 volume book with massive amounts of sample code. Chapter 12 in volume 1 gives sample code for overloading every possible operator. http://mindview.net/Books/TICPP/ThinkingInCPP2e.html -- John Carson Jul 23 '05 #4

 P: n/a sandSpiderX wrote: Hi, How do i use this definition of overloaded operator, T& operator*(T*); You cannot overload this operator. T* is a built-in type, and operators that only have built-in types as parameters cannot be user-defined. Jul 23 '05 #5

 P: n/a Hi, Rolf, This is confusing.... operators that only have built-in types as parameters cannot be user-defined. However, this is the goal of operator overloading. Every operator which is overloaded has built in type as parameters or operands. AFAIK, this is the central core to operator overloading....to enable operators work on user defined types which have only operands as built in types... Suggest sandSpiderX. Jul 23 '05 #6

 P: n/a sandSpiderX wrote: Hi, Rolf, This is confusing.... operators that only have built-in types as parameters cannot be user-defined. However, this is the goal of operator overloading. No, it isn't. The goal is to extend the behavior of C++ with user-defined types, not to modify the built-in behavior. Every operator which is overloaded has built in type as parameters or operands. No. You can only overload operators for user-defined types. AFAIK, this is the central core to operator overloading....to enable operators work on user defined types which have only operands as built in types... No. The parameters are what is used to select a specific operator. If those are only built-in types, how would the compiler know that you do not want the built-in operator but the other one? Which is more or less the question you were initially asking for. Jul 23 '05 #7

### This discussion thread is closed

Replies have been disabled for this discussion.