在同一行使用两个运算符 [英] using two operators in same line

查看:93
本文介绍了在同一行使用两个运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello程序员,

我正在尝试写一个有两个运算符的类#和< =,所以

我可以这样做。< br $> b $ b ...

阵列mArray;

.....

#4 mArray< = 5; //这可能让#操作员在LHS上没有任何东西吗?我可以得到< =运算符工作,mArray< = 5,但是不能认为
$无论如何b $ b结合两个运营商togeather!可以返回参考

数组在< =运算符中执行类似(4#mArray< = 5)的工作。


想要我喜欢有#4 mArray< = 5;

但我可以使用其他一些版本,4#mArray< = 5或(mArray< =

5)# 4(真的不喜欢这个!)


任何建议,评论和帮助?


类定义数组

class Array

{

public:

Array();

~Array():

operator< =(const int inIndex){mIndex = inIndex;}

朋友? operotor#(const Array& in Array)

private:

int mIndex;

};

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 写道:
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:

你好程序员,

我正在尝试写一个有两个运算符的类#和< =,所以

我可以做这样的事情。

..

阵列mArray;

....

#4 mArray< = 5; //这可能让#操作员在LHS上没有任何东西吗?我可以得到< =运算符工作,mArray< = 5,但是不能认为
$无论如何b $ b结合两个运营商togeather!可以返回参考

数组在< =运算符中执行类似(4#mArray< = 5)的工作。


想要我喜欢有#4 mArray< = 5;

但我可以使用其他一些版本,4#mArray< = 5或(mArray< =

5)# 4(真的不喜欢这个!)


任何建议,评论和帮助?


类定义数组

class Array

{

public:

Array();

~Array():

operator< =(const int inIndex){mIndex = inIndex;}

朋友? operotor#(const Array& in Array)

private:

int mIndex;

};
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;
};


***** @ yahoo.com 写道:

Hello程序员,

我正在尝试写一个有两个运算符的类#和< =,所以

我可以做这样的事情。

..

阵列mArray;

....

#4 mArray< = 5; //这可能让#操作员在LHS上没有任何东西吗?我可以得到< =运算符工作,mArray< = 5,但是不能认为
$无论如何b $ b结合两个运营商togeather!可以返回参考

数组在< =运算符中执行类似(4#mArray< = 5)的工作。


想要我喜欢有#4 mArray< = 5;

但我可以使用其他一些版本,4#mArray< = 5或(mArray< =

5)# 4(真的不喜欢这个!)


任何建议,评论和帮助?


类定义数组

class Array

{

public:

Array();

~Array():

operator< =(const int inIndex){mIndex = inIndex;}

朋友? operotor#(const Array& in Array)

private:

int mIndex;

};
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.


谢谢,很高兴知道,如何使用那么^或@

red floyd写道:
thanks, good to know, how about using then ^ or @
red floyd wrote:
**** *@yahoo.com 写道:

Hello程序员,

我正在尝试写一个有两个运算符的类#和< =,所以

我可以做这样的事情。

..

阵列mArray;

....

#4 mArray< = 5; //这可能让#操作员在LHS上没有任何东西吗?我可以得到< =运算符工作,mArray< = 5,但是不能认为
$无论如何b $ b结合两个运营商togeather!可以返回参考

数组在< =运算符中执行类似(4#mArray< = 5)的工作。


想要我喜欢有#4 mArray< = 5;

但我可以使用其他一些版本,4#mArray< = 5或(mArray< =

5)# 4(真的不喜欢这个!)


任何建议,评论和帮助?


类定义数组

class Array

{

public:

Array();

~Array():

operator< =(const int inIndex){mIndex = inIndex;}

朋友? operotor#(const Array& in Array)

private:

int mIndex;

};
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.


这篇关于在同一行使用两个运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆