string operator = in C++

operator =: This operator assigns the value of str to this string.

Parameters: 

__str – Source string (or string to be assigned to the str).

Syntax:

str = __str

For Example:

str = "abc" => String becomes "abc".

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string str;
    str = "abc";

    cout << str << "\n";


    return 0;
}


No comments:

Post a Comment