473,320 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

using T& operator*(T*);

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 2714
"sandSpiderX" <m7*********@gmail.com> 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
Can I see some code now
Some example of this ....

Jul 23 '05 #3
"sandSpiderX" <m7*********@gmail.com> 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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: siliconwafer | last post by:
Hi, In case of following expression: c = a && --b; if a is 0,b is not evaluated and c directly becomes 0. Does this mean that && operator is given a higher precedence over '--'operator? as...
17
by: orekinbck | last post by:
Hi There Say I want to check if object1.Property1 is equal to a value, but object1 could be null. At the moment I have code like this: if (object1 != null) { if (object1.Property ==...
8
by: John Pass | last post by:
When displaying output in a MessageBox, using a variable Output as string, the &= operator is used instead of the = operator. In which cases is the &= operator used?
3
by: Nathan Sokalski | last post by:
I have a VB.NET function that I am using in an ASP.NET page. The code creates a String, which contains && (the JavaScript Logical AND operator) and is used as part of the JavaScript sent to the...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
1
by: developereo | last post by:
Hi folks, Can somebodyshed some light on this problem? class Interface { protected: Interface() { ...} virtual ~Interface() { ... } public:
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.