I am practicing on LeetCode.
I have the following CPP code:
string s="abcd";
queue<string> q;
string temp;
temp=s[2];
queue.push(temp);
Error:
Line 5: conversion from '__gnu_cxx::__alloc_traits >::value_type {aka char}' to non-scalar type 'std::__cxx11::string {aka std::__cxx11::basic_string}' requested
I am wondering why this happen? I can't really change thte structure of this because temp will be growing over time (eg., temp='a'+'b'+'c'; queue.push(temp));