标签: operator-keyword

丢弃const限定符

为什么不允许丢弃const限定符?假设我们写道:

#include <iostream>

struct A
{
    void operator=(const A&){ std::cout << "A&" << std::endl; }
    void operator=(const A&&){ std::cout << "A&&" << std::endl; }
};

const A a;
A b;

int main()
{
    a = b; //Error: discarding qualifier
}
Run Code Online (Sandbox Code Playgroud)

有人不能提供标准不允许的参考吗?

c++ class operator-keyword

-2
推荐指数
1
解决办法
110
查看次数

C#如何检测字符串中的运算符来计算?

假设程序接收输入字符串"8*10+6/2"并且应该输出83,在这种情况下.如何处理运营商?

我可以将字符串切成单个字符串,然后检测它是数字还是运算符.如果是操作员我可以将其转换为int.但我不知道如何处理运算符,以便计算工作.

c# operator-keyword

-3
推荐指数
1
解决办法
1578
查看次数

std :: vector operator []与at()访问

<std :: Vector> Operator [] vs. at()

=========================================

我在某处读到,只有索引访问运算符[]和()成员函数之间的区别在于()也检查索引是否有效.但是,从以下代码中扣除,似乎存在差异

std::vector<std::string>* namesList = readNamesFile("namesList.txt");
std::vector<Rabbit> rabbits;

const int numNAMES = namesList->size();

for (int i = 0; i < 5; i++)
{
    rnd = rand() % numNAMES;
    rabbits.push_back(Rabbit(namesList[i]));
}
Run Code Online (Sandbox Code Playgroud)

上面的代码抛出

error C2440: '<function-style-cast>' : cannot convert from 'std::vector<std::string,std::allocator<_Ty>>' to 'Rabbit'
1>          with
1>          [
1>              _Ty=std::string
1>          ]
1>          No constructor could take the source type, or constructor overload resolution was ambiguous
Run Code Online (Sandbox Code Playgroud)

此外,如果我将鼠标悬停在上面(见下文)

rabbits.push_back(Rabbit(namesList[i]));
Run Code Online (Sandbox Code Playgroud)

                                     ^^^^^^^我读了intelliSense:

Error: no instance of constructor …
Run Code Online (Sandbox Code Playgroud)

c++ vector stdvector operator-keyword

-3
推荐指数
1
解决办法
790
查看次数

整数上的Ruby &&运算符

有没有人知道&&和||的含义 什么时候应用于Ruby中的整数?

以下是IRB中&&和||时的一些示例 适用于整数:

>> 1 && 2
=> 2

>> 2 && 1
=> 1

>> 15 && 20
=> 20

>> 20 && 15
=> 15

>> 0 && -1
=> -1

>> -1 && -2
=> -2

>> 1 || 2
=> 1

>> 2 || 1
=> 2
Run Code Online (Sandbox Code Playgroud)

ruby operator-keyword

-3
推荐指数
1
解决办法
260
查看次数

什么参数'=='决定平等?

当我们用Java编写以下代码时:

object1 == object2;

运营商'=='在什么基础上决定平等?

java operator-keyword

-4
推荐指数
1
解决办法
229
查看次数

Java中的*=意味着什么?

我正在阅读一个教程,我找到了这个操作符,但我不确定它是做什么的.

int number = Integer.parseInt(tfInput.getText());

数字*=数字;

tfResult.setText(number +"");

谢谢.

java string int operator-keyword

-4
推荐指数
1
解决办法
8466
查看次数

找不到"=="运算符

显然这个prgoram不起作用.软件告诉我'=='运算符丢失了.有些人可以告诉我该怎么做并解释为什么他/她的解决方案有效吗?

#include <iostream>
using namespace std;

int main() {

    int var{ 0 };

    cout << "Bitte eine Ganzzahl eingeben: ";
    if ((cin >> var) == false) {
        cerr << "Falsche Eingabe - Keine Zahl\n";
        exit(1);
    }


    system("pause");
    //return 0;
}
Run Code Online (Sandbox Code Playgroud)

而我们正在努力.为什么可以在if statemant中执行'cin'?我会在if statemant之前使用'cin'.

c++ if-statement operator-keyword

-4
推荐指数
1
解决办法
193
查看次数

什么是C++中的`&|`?

在研究C++运算符重载时,我偶然发现了一个页面:

新的运算符,例如**,<>或&| 无法创建.

请问&|在C++中真的存在吗?如果是这样,它叫什么,它做了什么?

---更新---

对于将来想知道答案的人:句子意味着你不能创建"新"运算符,而不是newC++中的新运算符和运算符.它的意思是

语言中不存在的运算符,例如**,<>和&|,无法创建

c++ operator-keyword

-4
推荐指数
1
解决办法
134
查看次数

我应该将符号称为"|"?管道或位运算符

请看以下内容:

def update_page_info(url):
    # fetch_page -> parse_page -> store_page
    chain = fetch_page.s(url) | parse_page.s() | store_page_info.s(url)
    chain()

@app.task()
def fetch_page(url):
    return myhttplib.get(url)

@app.task()
def parse_page(page):
    return myparser.parse_document(page)

@app.task(ignore_result=True)
def store_page_info(info, url):
    PageInfo.objects.create(url=url, info=info)
Run Code Online (Sandbox Code Playgroud)

python naming operator-keyword

-4
推荐指数
1
解决办法
615
查看次数

什么样的运算符是*(++ ptr)?

我对C很新,有时我会遇到奇怪的符号,特别是与指针有关.

一个很短的例子:

....
real *ptr;
real delta_force;
for(i<particles;...)
{
  ...some calculations
  ptr=&FORCE(i,...);  //FORCE is a macro returning the current force on a particle
  *(++ptr) += delta_force;
  ...
 }
...
Run Code Online (Sandbox Code Playgroud)

我怎么解释*(++ptr)

c pointers notation operator-keyword

-5
推荐指数
1
解决办法
98
查看次数

标签 统计

operator-keyword ×10

c++ ×4

java ×2

c ×1

c# ×1

class ×1

if-statement ×1

int ×1

naming ×1

notation ×1

pointers ×1

python ×1

ruby ×1

stdvector ×1

string ×1

vector ×1