Knowee
Questions
Features
Study Tools

codes/mainc-5557-1714197819.2519343.cpp: In member function 'std::vector StringCalculator::process(std::__cxx11::string)':codes/mainc-5557-1714197819.2519343.cpp:14:25: error: 'count' is not a member of 'std' } else if (std::count(input.begin(), input.end(), ' ') == 3) { ^~~~~codes/mainc-5557-1714197819.2519343.cpp:14:25: note: suggested alternative: 'cout' } else if (std::count(input.begin(), input.end(), ' ') == 3) { ^~~~~ coutcodes/mainc-5557-1714197819.2519343.cpp:21:20: error: could not convert 'concatenatedString' from 'std::__cxx11::string {aka std::__cxx11::basic_string}' to 'std::vector' return concatenatedString; ^~~~~~~~~~~~~~~~~~codes/mainc-5557-1714197819.2519343.cpp:23:20: error: could not convert '"Invalid input"' from 'const char [14]' to 'std::vector' return "Invalid input"; ^~~~~~~~~~~~~~~

Question

codes/mainc-5557-1714197819.2519343.cpp: In member function 'std::vector StringCalculator::process(std::__cxx11::string)':codes/mainc-5557-1714197819.2519343.cpp:14:25: error: 'count' is not a member of 'std' } else if (std::count(input.begin(), input.end(), ' ') == 3) { ^codes/mainc-5557-1714197819.2519343.cpp:14:25: note: suggested alternative: 'cout' } else if (std::count(input.begin(), input.end(), ' ') == 3) { ^ coutcodes/mainc-5557-1714197819.2519343.cpp:21:20: error: could not convert 'concatenatedString' from 'std::__cxx11::string {aka std::__cxx11::basic_string}' to 'std::vector' return concatenatedString; ^~~~codes/mainc-5557-1714197819.2519343.cpp:23:20: error: could not convert '"Invalid input"' from 'const char [14]' to 'std::vector' return "Invalid input"; ^

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The error messages you're seeing are due to a couple of issues in your C++ code:

  1. std::count is not a member of std: This error is because the count function is not directly under the std namespace. It's actually part of the <algorithm> library. So, you need to include that library at the beginning of your code using #include <algorithm>.

  2. Could not convert 'concatenatedString' from 'std::__cxx11::string' to 'std::vector': This error is because you're trying to return a std::string where a std::vector is expected. You need to make sure that the return type of your function matches what you're actually returning.

  3. Could not convert '"Invalid input"' from 'const char [14]' to 'std::vector': This is the same issue as above. You're trying to return a const char array where a std::vector is expected. Again, make sure the return type of your function matches what you're actually returning.

This problem has been solved

Similar Questions

sol.cpp: In function ‘int main()’:sol.cpp:8:83: error: ‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’} has no member named ‘kength’; did you mean ‘length’? 8 | cout<<one<<" "<<two<<" "<<three<<" "<<" - "<<(one.length()+two.length()+three.kength())<<endl; | ^~~~~~ | length

What is the output of this C++ program? #include <iostream>#include <string>#include <sstream>using namespace std;int main (){string mystr;float price = 0;int quantity = 0;cout << "Enter price: ";getline (cin, mystr);stringstream(mystr) >> price;cout << "Enter quantity: ";getline (cin, mystr);stringstream(mystr) >> quantity;cout << "Total price: " << price * quantity << endl;return 0;} Depends on value you enterNone of the mentionedError50

./Solution.cpp: In member function 'std::vector<int> Solution::findUnion(int*, int*, int, int)':./Solution.cpp:16:19: error: 'begin' was not declared in this scope for(int i:arr1){ ^./Solution.cpp:16:19: note: suggested alternatives:In file included from /usr/local/include/c++/5.4.0/x86_64-linux-gnu/bits/stdc++.h:94:0, from ./Solution.cpp:2:/usr/local/include/c++/5.4.0/valarray:1206:5: note: 'std::begin' begin(const valarray<_Tp>& __va)

Write a C++ Program to Show Counter using Constructor.input and output Current count: 0Current count: 3Current count: 1

What is the output of the following snippet? #include <iostream> #include <string> using namespace std; int main() { int i = 2; string s = "2"; cout << s + i; } 2 4 Compilation fails 2

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.