基本代码中的"运算符=不匹配"错误
'No match for operator=' error in basic code
我对编码很陌生(就像一天前一样),所以你可以假设我什么都不知道。我发现调试我极其简单的程序非常困难,我在网上看到的大多数帮助要么超出了我的想象,要么过于针对程序。
这就是我现在正在编写的代码。
/*
* LogBase8.cpp
*
* Created on: Feb 13, 2015
* Author: Holly
*/
//This program calculates the log base 8 of a number.
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
//Declare variables and constants.
float x, log_8_x;
int main()
{
//Prompt user to input number.
cout << "This program will calculate the log base 8 of a number. Input number to calculate" << endl;
cin >> x;
//Calculate log_8_x.
log_8_x = log(x) / log(8);
//Print log_8_x.
cout << "The log base 8 of " << x << " is " << log_8_x << endl;
//End main.
return (0);
}
我在log_8_x = log(x) / log(8);
行中有一个错误,上面写着
no match for 'operator=' (operand types are 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' and 'double')
如果相关的话,我正在使用Eclipse。
正如问题中所述,您还有其他错误,但无论如何都要放一个来转义字符串中出现的换行符
cout << "This program will calculate the log base 8 of a number. Input
修复编译错误。
请在这里查看完整的工作样本。
相关文章:
- 在使用累加时,C++中的运算符+不匹配
- 我在 .h 中有一个枚举类,并且在.cpp错误中有一个运算符重载:与"运算符<<不匹配
- 为什么我收到错误:"运算符<<不匹配?
- 映射迭代器与运算符不匹配
- 与"运算符>>"不匹配(操作数类型为"QDataStream"和"QJsonObject")
- 与标准中的"运算符<<"不匹配
- 运算符不匹配*=
- 不断收到错误" 与"运算符>>不匹配";
- 编译我的 3 个文件时,我收到错误,说"运算符="不匹配
- C++ 模板与运算符<不匹配
- 与"运算符="不匹配
- 代码块编译错误与运算符<<不匹配
- 错误:运算符 [] 不匹配。在比较列表中的 int 和 int 时<int>,
- 解决错误:运算符 [] 不匹配
- 错误:与"运算符>>"不匹配(操作数类型为"std::istream
- 与"运算符[]"不匹配(操作数类型为"std::unique_ptr<std::vector<int> >"和"int")
- 错误:与“运算符 []”不匹配
- 与"运算符<<不匹配
- 错误:与"运算符[]"不匹配(操作数类型为"QVector<int>"和"QCharRef")
- 错误:"运算符>>"不匹配 重载 istream 运算符