I am having a problem with getting my program to compile. This is a sample of my code but it an error comes up and says " binary '||' : no global operator found which takes type 'std::string' (or there is no acceptable conversion)". Is there anyway around this or what should I do?

#include <iostream>
#include <string>
#include <fstream>
#include <cstdio>
#include <cctype>
#include <iomanip>
#include <cstdlib>


using namespace std;
string one, two, three, four, five, six, seven, eight, nine;

int main()
{
	string productNumber;

	cout << endl << setw(40) << "ENTER IN PRODUCT NUMBER: ";
	cin >> productNumber;

	string first = productNumber.substr(0,1), buildCode = productNumber.substr(2,2), micron = productNumber.substr(4,2);
	string lenght = productNumber.substr(6,1);
	string endone = productNumber.substr(7,1);
	string endtwo = productNumber.substr(8,1);
	string oring = productNumber.substr(9,1);
	string industry = productNumber.substr(10,1);

	string str1("polypropylene microfiber"), 
		   str2("glass microfiber"), 
		   str3("halar all fluoropolymer microfiber"),
		   str4("polyproplyene microfiber"),
		   str5("gore PTEE membrane"),
		   str6("modified polyethersulfone membrane"),
		   str7("hydrophilic nylon 66n membrane"),
		   str8("polycarbonate track-etch membrane"),
		   str9("polypropylene membrane"),
		   str10("0.03"),
		   str11("0.05"),
		   str12("0.1"),
		   str13("0.2"),
		   str14("0.45"),
		   str15("0.65"),
		   str16("1.0"),
		   str17("2.0"),
		   str18("3.0"),
		   str19("4.0"),
		   str20("5.0"),
		   str21("10"),
		   str22("20"),
		   str23("25"),
		   str24("30"),
		   str25("40");

	if (first == 'F' || first == 'f')
	{
		one = "Nominally";
		four = "nominal";
	}

	else if (first == 'M' || first == 'm')
	{
		one = "Absolutly";
		four = "absolute";
	}

	cout << setw(40) <<  "\n\n*** DESCRIPTION ***\n";
	cout << one << " rated " << two << " cartridge filter with a " << three << " micron " << four << " retention rating.  This filter has a nominal lenght of " << five << " inches and has a " << six << " connection on the open end and " << seven << " on the closed end.  The filter has a " << eight << " elastomeric seal and is designed for use in the " << nine << endl;


	return 0;
}

Recommended Answers

All 2 Replies

"first" is declared as a std::string, so if you want to use the comparison-operator, you should use double quotes, not single. Single quotes are only for one character.

so change:

if (first == 'F' || first == 'f')
	{
		one = "Nominally";
		four = "nominal";
	}

	else if (first == 'M' || first == 'm')
	{
		one = "Absolutly";
		four = "absolute";
	}

to:

if (first == "F" || first == "f")
	{
...
	}

	else if (first == "M" || first == "m")
	{
...
	}

thanks that worked great!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.