1 //22-Combination assignment operator and relational operator. CPP: The entry point that defines the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7#include <array>8#include <string>9 using namespacestd;Ten One intMain () A { - // + - * / - //+ = = *=/=%= combination assignment operator the intA = at, B = in; -A + = B;//a=a+b; -cout << a <<Endl; -A-=b; +cout << a <<Endl; -a*=b; +cout << a <<Endl; AA/=b; atcout << a <<Endl; -A%=b; -cout << a <<Endl; - - //> >= < <= = = = = Relational operator - BOOLres = the> the; incout << Res <<Endl; - intE = -, f= -; tocout << (E > F) <<Endl; + - //string comparison the CharStr1[] ="Uimodel"; * CharStr2[] ="Uimode1"; $cout << (str1 = = str2) <<endl;//The array itself is a pointer, in different addresses, the default comparison is the address, so the values are not equal, 0 is false. Panax Notoginseng //What if the data in the string (pointer) address is judged to be the same? -strcmp (str1, str2);//The comparison is the value in the string address, 0 equals not 0 thecout << strcmp (str1, str2) << Endl;//If you are comparing a C-style string, you need to compare it with the strcmp function. + A //C + + style string Direct comparison on the line the stringSTR3 ="Uimodel1"; + stringSTR4 ="Uimodel2"; -cout << (Str3 = = STR4) << Endl;//false, the output result is 0. $ $ intT; -CIN >>T; - return 0; the}
Fundamentals of C + + programming 122-combining assignment operators and relational operators