A program
Feb 28, 2013 at 9:14am Feb 28, 2013 at 9:14am UTC
Please help, I keep getting the operator error
error C2677: binary '||' : no global operator found which takes type 'std::string' (or there is no acceptable conversion)
Here is my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
void main()
{
//Printing on screen
long long R = 0, G = 0, B = 0;
int Repeat = 1, xy = 10;
HDC dc;
dc=GetDC(0);
HBRUSH dr;
string sRepeat;
sRepeat = "open" ;
while (Repeat==1 || sRepeat = "open" )
{
cout << "Choose value of R: " ;
cin >> R;
cout << "Choose value of G: " ;
cin >> G;
cout << "Choose the value of B: " ;
cin >> B;
dr=CreateSolidBrush(RGB(R,G,B));
SelectObject(dc,dr);
Rectangle(dc,xy,xy,500,500);
cout << "Would you like to print another one? 1 for yes and 0 for no: " ;
cin >> Repeat;
cin >> sRepeat;
if (Repeat == 0)
{
sRepeat = "close" ;
}
else if (Repeat == 1)
{
sRepeat = "open" ;
}
xy += 10;
}
if (Repeat == 0 || sRepeat = "close" )
{
DeleteObject(dr);
ReleaseDC(0,dc);
cout << "Press anything to exit" ;
cin.get()
}
Please help, I'm doing the string because whenever the input for the int is a letter, it glitches and prints boxes on the screen continuously with the previous colour
Feb 28, 2013 at 10:22am Feb 28, 2013 at 10:22am UTC
You are assigning instead of comparing.
Feb 28, 2013 at 10:36am Feb 28, 2013 at 10:36am UTC
?
Feb 28, 2013 at 10:36am Feb 28, 2013 at 10:36am UTC
I changed the = to ==
Topic archived. No new replies allowed.