Hello programmers,
I am trying to write a class which has a two operators # and <=, so
that I can do something like this.
...
Array mArray;
.....
#4 mArray <= 5; //is this possible to have for # operator to have
nothing on LHS, I can get <= operator work, mArray <=5, but can't think
of anyway to combined both operator togeather! can return refrence to
Array in <= operator to do something like (4# mArray <= 5) to work.
Idealy I like to have #4 mArray <= 5;
but I can live with some other versions, 4# mArray <= 5 or (mArray <=
5) #4 (really not prefer this!)
Any suggestions, comments, help?
class defination for Array
class Array
{
public:
Array();
~Array():
operator<= (const int inIndex) {mIndex = inIndex;}
friend ?? operotor# (const Array& in Array)
private:
int mIndex;
}; 10 1561
sorry, also forgot one more important point,
how can I have a higher precedence set for <= operator. Assignments
should always evaluate <= first and after that #)
thanks an*****@yahoo.com wrote:
Hello programmers,
I am trying to write a class which has a two operators # and <=, so
that I can do something like this.
..
Array mArray;
....
#4 mArray <= 5; //is this possible to have for # operator to have
nothing on LHS, I can get <= operator work, mArray <=5, but can't think
of anyway to combined both operator togeather! can return refrence to
Array in <= operator to do something like (4# mArray <= 5) to work.
Idealy I like to have #4 mArray <= 5;
but I can live with some other versions, 4# mArray <= 5 or (mArray <=
5) #4 (really not prefer this!)
Any suggestions, comments, help?
class defination for Array
class Array
{
public:
Array();
~Array():
operator<= (const int inIndex) {mIndex = inIndex;}
friend ?? operotor# (const Array& in Array)
private:
int mIndex;
};
an*****@yahoo.com wrote:
Hello programmers,
I am trying to write a class which has a two operators # and <=, so
that I can do something like this.
..
Array mArray;
....
#4 mArray <= 5; //is this possible to have for # operator to have
nothing on LHS, I can get <= operator work, mArray <=5, but can't think
of anyway to combined both operator togeather! can return refrence to
Array in <= operator to do something like (4# mArray <= 5) to work.
Idealy I like to have #4 mArray <= 5;
but I can live with some other versions, 4# mArray <= 5 or (mArray <=
5) #4 (really not prefer this!)
Any suggestions, comments, help?
class defination for Array
class Array
{
public:
Array();
~Array():
operator<= (const int inIndex) {mIndex = inIndex;}
friend ?? operotor# (const Array& in Array)
private:
int mIndex;
};
First of all, you *can't* define operator#. There is no such operator.
Given that, you're toast anyways.
thanks, good to know, how about using then ^ or @
red floyd wrote:
an*****@yahoo.com wrote:
Hello programmers,
I am trying to write a class which has a two operators # and <=, so
that I can do something like this.
..
Array mArray;
....
#4 mArray <= 5; //is this possible to have for # operator to have
nothing on LHS, I can get <= operator work, mArray <=5, but can't think
of anyway to combined both operator togeather! can return refrence to
Array in <= operator to do something like (4# mArray <= 5) to work.
Idealy I like to have #4 mArray <= 5;
but I can live with some other versions, 4# mArray <= 5 or (mArray <=
5) #4 (really not prefer this!)
Any suggestions, comments, help?
class defination for Array
class Array
{
public:
Array();
~Array():
operator<= (const int inIndex) {mIndex = inIndex;}
friend ?? operotor# (const Array& in Array)
private:
int mIndex;
};
First of all, you *can't* define operator#. There is no such operator.
Given that, you're toast anyways.
an*****@yahoo.com wrote:
red floyd wrote:
an*****@yahoo.com wrote:
I am trying to write a class which has a two operators # and <=, so
[snips, and top posting corrected]
First of all, you *can't* define operator#. There is no such operator.
Given that, you're toast anyways.
thanks, good to know, how about using then ^ or @
Well, what would operator # do if it did exist? What are you
trying to get from it?
Um. I don't think there's an operator @, is there?
Socks
Puppet_Sock wrote:
Um. I don't think there's an operator @, is there?
Socks
@ and $ do not exist in the C++ syntax anywhere
(outside of char/string literals).
if operator # exit, I like to do something
operator# (const int inCount) {mIndex = mIndex * inCount;}
this is just example.
Puppet_Sock wrote:
an*****@yahoo.com wrote:
red floyd wrote:
an*****@yahoo.com wrote:
I am trying to write a class which has a two operators # and <=, so
[snips, and top posting corrected]
First of all, you *can't* define operator#. There is no such operator.
Given that, you're toast anyways.
thanks, good to know, how about using then ^ or @
Well, what would operator # do if it did exist? What are you
trying to get from it?
Um. I don't think there's an operator @, is there?
Socks
an*****@yahoo.com schrieb:
Hello programmers,
I am trying to write a class which has a two operators # and <=, so
that I can do something like this.
..
Array mArray;
....
#4 mArray <= 5; //is this possible to have for # operator to have
nothing on LHS, I can get <= operator work, mArray <=5, but can't think
of anyway to combined both operator togeather! can return refrence to
Array in <= operator to do something like (4# mArray <= 5) to work.
[...]
There is no # operator, and I doubt that your <= operator is an "lesser
equal" operator. Don't confuse other compilers by changing the meaning of
operators.
Read the FAQ on operator overloading: http://www.parashift.com/c++-faq-lit...erloading.html
--
Thomas http://www.netmeister.org/news/learn2quote.html an*****@yahoo.com wrote:
sorry, also forgot one more important point,
how can I have a higher precedence set for <= operator. Assignments
should always evaluate <= first and after that #)
You can not change the precedence (or associativity) of operators. This
is why it is not recommened to overload operator^ to do exponentiation,
for example; see: http://www.parashift.com/c++-faq-lit....html#faq-13.7
--
Marcus Kwok
Replace 'invalid' with 'net' to reply an*****@yahoo.com wrote:
if operator # exit, I like to do something
operator# (const int inCount) {mIndex = mIndex * inCount;}
this is just example.
Operator overloading is for doing things with your own types that are
logically similar to what the same operator would do with built-in types.
It is supposed to help you extend the langage, not change it into a
different one. Since there is no operator# for built-in types, there is
nothing useful it could do and so you can't define your own either.
You can overload operator^, but only as a binary operator (i.e. having two
arguments, one on the left and one on the right side). It's supposed to do
a bitwise exclusive or of the two arguments.
In article <11*********************@f16g2000cwb.googlegroups. com>, an*****@yahoo.com wrote:
Hello programmers,
I am trying to write a class which has a two operators # and <=, so
that I can do something like this.
You cannot invent operators, all you can do is implement the operators
that already exist.
--
There are two things that simply cannot be doubted, logic and perception.
Doubt those, and you no longer*have anyone to discuss your doubts with,
nor any ability to discuss them. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andy Jarrell |
last post by:
I'm trying to inherit from a specific class that has an overloaded operator. The problem I'm getting is that certain
overloaded operators don't seem to come with the inheritance. For example:
...
|
by: Lionel B |
last post by:
Greetings,
I am trying to implement "element-wise" arithmetic operators for a class
along the following lines (this is a simplified example):
// ----- BEGIN CODE -----
struct X
{
int a,b;
|
by: Tony Johansson |
last post by:
Hello Experts!!
This class template and main works perfectly fine.
I have this class template called Handle that has a pointer declared as T*
body;
As you can see I have a reference counter in...
|
by: Craig O'Shannessy |
last post by:
Hi all,
Just thought I'd mention that I really think this problem needs to be
fixed. I
I'm patching the 7.4RC1 JDBC drivers as we speak due to this optimiser
bug, and it's the third time...
|
by: Fabrizio |
last post by:
(Sorry for the crosspost, but I really don't know which is the right
newsgroup!)
Hi all,
I try to change the password to a user that as to change the password at
first logon:
try
{
|
by: spibou |
last post by:
This concerns the Wikipedia article on C and C++ operators:
http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B
Until very recently the first table in the page was a very
useful one on the...
|
by: Zach |
last post by:
Can someone list the various macro operators and what they mean. Came
across a function macro:
#define max(a, b) ((a)>(b)?(a):(b))
What does "?" amd ":" mean in this statement?
Zach
|
by: debasisdas |
last post by:
Using Subqueries
==================
The sub query is often referred to as a nested SELECT, Sub - SELECT, or inner SELECT statement.
The sub query executes once before the main query.
The...
|
by: debasisdas |
last post by:
Using Co-related sub query
========================
While a subquery is evaluated only once for each table, a correlated subquery is evaluated once for each row.
Sub query can take value from...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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...
|
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)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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
|
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...
| |