我在我的程序中有一个语句,它对两个向量的元素进行比较
if(!*(it2+3).compare(*(lines_in_file.begin())))
我得到的编译器错误是:
test_file.cpp:140: error: 'class __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >' has no member named 'compare'
it2的类型是:
vecto
对于这个简单的问题,我很抱歉,但我不明白为什么这个简单的程序不能工作。
a[0]应该是"a"以外的其他什么
#include <iostream>
using namespace std;
int main(){
string a = "abcd";
string b = "a";
if (a[0]==b){//<------problem here
cout << a << endl;
}
return 0;
}
返回错误的
不匹配“
这可能会被嘲笑,因为我可能非常愚蠢,但是我可以在if语句中使用多个字符串作为条件吗?
#pragma once
#include <iostream>
#include <string>
#include "Baxter.h"
#include "Inventory.h"
#include "Room1Items.h"
int woman = 6;
int children = 5;
int inputNumberOfAnimalsToSave;
int numberOfAnimals;
int numberOfAn
下面的代码当我检查K或Y是否大于时,使用什么方法来比较两个不同的字符串?位数?
#include <iostream>
#include <string>
using namespace std;
int main() {
string y = "can't";
string k = "solve";
if(k > y){
cout << "k is bigger";
}else {
cout << "y i
我有一些代码,实际上如下:
String a;
String b;
a = get_string_from_complex_procedure_1();
b = get_string_from_complex_procedure_2();
if (a != b)
{
put_up_error_dialog("["+a+"] != ["+b+"]");
}
代码的设计使得a和b最终应该是相同的,而且实际上大多数情况下它们是相同的,但偶尔我会看到错误对话框出现。但是,令人困惑的是,当对话框报告时,这两个字符串与我看起来是相同的。我想知道什么样