Knowee
Questions
Features
Study Tools

/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(); | ^

Question

/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(); | ^

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

Solution

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

  1. The function item is declared without a return type. In C++, every function must have a return type. If you don't want to return anything, you should use void. However, from the context, it seems like item is supposed to be a constructor for a class Item. Constructors in C++ should have the same name as the class, so you should rename item to Item.

  2. The Item class doesn't have a constructor that takes two arguments (string id, int days). You need to declare and define this constructor in the Item class.

  3. The dvd class is declared with a constructor that takes a String (with a capital S) as an argument. C++ is case-sensitive, so String and string are not the same. You should change String to string.

  4. The dvd and magazine classes are trying to call a two-argument constructor of the Item class, but it doesn't exist. As mentioned above, you need to add this constructor to the Item class.

  5. In the main function, you're trying to create an instance of the dvd class with two arguments, but this constructor doesn't exist. You need to add it to the dvd class.

  6. Also in the main function, you're trying to use a variable m that hasn't been declared. You need to declare m before you can use it.

I hope this helps! Let me know if you have any other questions.

This problem has been solved

Similar Questions

/home/ubuntu/Main.cpp:24:15: error: expected ‘)’ before ‘id’ 24 | dvd(String id,int days) : Item(id,days){} | ~ ^~~ | )/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:46:17: error: no matching function for call to ‘dvd::dvd(std::string&, int&)’ 46 | dvd d(did,dd); | ^/home/ubuntu/Main.cpp:21:7: note: candidate: ‘dvd::dvd(const dvd&)’ 21 | class dvd : public Item | ^~~/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(); | ^

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

/home/ubuntu/Main.cpp:22:5: error: expected unqualified-id before ‘delete’ 22 | int delete(){ | ^~~~~~/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:72:13: error: ‘insert’ was not declared in this scope 72 | insert(item); | ^~~~~~/home/ubuntu/Main.cpp:75:63: error: expected primary-expression before ‘)’ token 75 | printf("Element deleted from queue is :%d",delete()); | ^

/home/ubuntu/Main.cpp:3:15: error: expected unqualified-id before ‘int’ 3 | char register(int weight, double height) { | ^~~/home/ubuntu/Main.cpp:3:15: error: expected ‘)’ before ‘int’ 3 | char register(int weight, double height) { | ~^~~ | )/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:30:16: error: expected primary-expression before ‘register’ 30 | category = register(weight, height); | ^~~~~~~~

Identify the issue in this C++ code snippet:class Car {public:int speed;void Car() { speed = 0; }};a.Missing data encapsulationb.Incorrect class constructor syntaxc.No errord.Inheritance misuse

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.