次のコードがあるとします。
#include <iostream>
#include <string>
#include <iomanip>
using namespace std; // or std::
int main()
{
    string s1{ "Apple" };
    cout << boolalpha;
    cout << (s1 == "Apple") << endl; //true
}私の質問は次のとおりです。システムはどのようにこれら2つをチェックしますか?s1はオブジェクト"Apple"ですが、Cスタイルの文字列リテラルです。
私の知る限り、異なるデータ型を比較することはできません。ここで何が欠けていますか?
                
                6
              
                  basic_string / operator_cmp(あなたの場合(7))。
                
                
                  
                    —
                     Jarod42 
                    
                  
                
              
                  Fwiw、あるタイプを別のタイプに変換できる限り、通常はそれらを比較できます。
                
                  
                    —
                    NathanOliver 
                    
                  
                
              std::stringc文字列からa を初期化できます。