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
Question
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
Solution
It seems like you have a typo in your code. The method to get the length of a string in C++ is .length(), not .kength(). So, you should replace three.kength() with three.length(). Here is the corrected line of code:
cout<<one<<" "<<two<<" "<<three<<" "<<" - "<<(one.length()+two.length()+three.length())<<endl;
Similar Questions
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"; ^~~~~~~~~~~~~~~
/home/ubuntu/Main.cpp:9:29: error: ISO C++ forbids declaration of ‘item’ with no type [-fpermissive] 9 | item(string id,int days) : itemid(id),daysoverdue(days){} | ^/home/ubuntu/Main.cpp: In member function ‘int Item::item(std::string, int)’:/home/ubuntu/Main.cpp:9:33: error: only constructors take member initializers 9 | item(string id,int days) : itemid(id),daysoverdue(days){} | ^~~~~~/home/ubuntu/Main.cpp:9:62: warning: no return statement in function returning non-void [-Wreturn-type] 9 | item(string id,int days) : itemid(id),daysoverdue(days){} | ^/home/ubuntu/Main.cpp: In constructor ‘book::book(std::string, int)’:/home/ubuntu/Main.cpp:15:44: error: no matching function for call to ‘Item::Item(std::string&, int&)’ 15 | book(string id,int days) : Item(id,days) {} | ^/home/ubuntu/Main.cpp:3:7: note: candidate: ‘Item::Item()’ 3 | class Item | ^~~~/home/ubuntu/Main.cpp:3:7: note: candidate expects 0 arguments, 2 provided/home/ubuntu/Main.cpp:3:7: note: candidate: ‘Item::Item(const Item&)’/home/ubuntu/Main.cpp:3:7: note: candidate expects 1 argument, 2 provided/home/ubuntu/Main.cpp:3:7: note: candidate: ‘Item::Item(Item&&)’/home/ubuntu/Main.cpp:3:7: note: candidate expects 1 argument, 2 provided/home/ubuntu/Main.cpp: At global scope:/home/ubuntu/Main.cpp:24:15: error: expected ‘)’ before ‘id’ 24 | dvd(String id,int days) : Item(id,days){} | ~ ^~~ | )/home/ubuntu/Main.cpp: In constructor ‘magazine::magazine(std::string, int)’:/home/ubuntu/Main.cpp:33:46: error: no matching function for call to ‘Item::Item(std::string&, int&)’ 33 | magazine(string id,int days):Item(id,days){} | ^/home/ubuntu/Main.cpp:3:7: note: candidate: ‘Item::Item()’ 3 | class Item | ^~~~/home/ubuntu/Main.cpp:3:7: note: candidate expects 0 arguments, 2 provided/home/ubuntu/Main.cpp:3:7: note: candidate: ‘Item::Item(const Item&)’/home/ubuntu/Main.cpp:3:7: note: candidate expects 1 argument, 2 provided/home/ubuntu/Main.cpp:3:7: note: candidate: ‘Item::Item(Item&&)’/home/ubuntu/Main.cpp:3:7: note: candidate expects 1 argument, 2 provided/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:46:25: error: no matching function for call to ‘dvd::dvd(std::string&, int&)’ 46 | dvd d(id,daysoverdue); | ^/home/ubuntu/Main.cpp:21:7: note: candidate: ‘dvd::dvd()’ 21 | class dvd : public Item | ^~~/home/ubuntu/Main.cpp:21:7: note: candidate expects 0 arguments, 2 provided/home/ubuntu/Main.cpp:21:7: note: candidate: ‘dvd::dvd(const dvd&)’/home/ubuntu/Main.cpp:21:7: note: candidate expects 1 argument, 2 provided/home/ubuntu/Main.cpp:21:7: note: candidate: ‘dvd::dvd(dvd&&)’/home/ubuntu/Main.cpp:21:7: note: candidate expects 1 argument, 2 provided/home/ubuntu/Main.cpp:49:23: error: ‘m’ was not declared in this scope 49 | d.calculatefees()+m.calculatefees(); | ^
codes/mainc-5557-1711047180.6225164.cpp: In function 'int main()':codes/mainc-5557-1711047180.6225164.cpp:40:28: error: 'class JobBid' has no member named 'getBidNumber'; did you mean 'bidNumber'? std::cout << lowestBid.getBidNumber() << std::endl; ^~~~~~~~~~~~ bidNumber
./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)
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
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.