0
[C++] Can someone tell me what's wrong with this code?
https://code.sololearn.com/cFi1J8mw19rC/?ref=app The objective is to add book names (or whatever, actually) to an array using an object, which has a constructor that calls a method that prompts you to add some books, and another method to print the books in the array (I used objects because I want to practice with them), but it outputs some kind of error (it doesn't work at all). If somebody could help me it would be great (I really don't get what is wrong)!!! Thanks!!!
6 Answers
+ 1
try using dynamic memory
string * arr=new string [x];
0
@Andrés04_ve, this means that the problem occurs due a lot of memory is used in the stack, or am I wrong.
Because I tried something similar and nothing happened, it is just to check, but thanks.
0
Additionally, the errors in Codeblockes are:
Line 28: invalid use of non-static data member 'library::columns'
Line 29 : from this location
Line 19: 'books' was not declared in this scope
Line 24: 'books' was not declared in this scope
Line 36 request for member 'showData' in 'obj', which is non-class type 'library ()'
0
1. in main function, you should modify obj() as obj;
2. in updateData function change arr = books ===> books = arr;
3. in private you should change the books[columns] as *books
Because the array members number should be a static number, use pointer can give the array's first element's address.
https://code.sololearn.com/cQQdjzIBM04h/#cpp
0
Thanks for your help