I have to create a program to store information for a book store using class.
I need to store names of 10 books,along with authors,publishers,cost,stock,quality etc....The Thing is I have to create a 2-D Array to to store book names,publishers literally everything and i have been getting this error while using 2-D array to store book names.
1. Invalid Use Of Non-Static DATA Member.
2. bookarray Was Not Declared in this scope.
3. Line 32 : cannot resolved address of overloaded function.
Actually there seems to be no problem if i do it without classes.
I could use dynamic allocation via pointers but question as strictly demanded a 2-d array.
This is my first time working with classes (it's only been 3 days,sorry if this is super dumb or just horrible coding) I have removed the unnecessary code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include<iostream>
using namespace std;
class STOCK
{
private :
int book_numbers ;
int book_name_size ;
public :
STOCK()
{
book_numbers = 10 ;
book_name_size = 50;
}
char bookarray[book_numbers][book_name_size];
int i ;
void readbooksnames()
{
for (i = 0 ; i < book_numbers ; ++i)
{
cin.getline(bookarray[i],book_name_size);
}
}
};
int main()
{
STOCK obj ;
obj.readbooksnames;
return 0 ;
}
|