Hi guys please help me, why in blj.sub and blj.hrg error which is of non-class type ?
struct data{
int jumlah[30];
int hrg[30];
int sub[30];
char barang[30];
int jum_beli, bayar,diskon;
float tot;
cout<<"Nama Barang : "; fflush(stdin);
gets(blj.barang); //Pengguna input nama barang disimpan pada array nama_barang
cout<<"Jumlah : ";
cin>>blj[i].jumlah; //Pengguna input jumlah disimpan pada array jumlah
cout<<"Harga : ";
cin>>blj[i].hrg; //Pengguna input harga disimpan pada array harga
blj[i].sub=blj.jumlah*blj.hrg; // Menjumlahkan Harga sub total barang
tot=blj.sub; //Menjumlahkan seluruh sub total barang
}
cout<<endl;
cout<<"STRUK BELANJA MINI MARKET ABC"<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<"No Barang Jumlah Harga Sub Total"<<endl;
for (int i=0;i<jum_beli;i++){
cout<<i+1<<setw(8)<<blj.barang<<setw(10)<<blj.jumlah<<setw(12)<<blj.hrg<<setw(12)<<blj.sub<<endl; //Menampilkan semua nilai array
}
cout<<"---------------------------------------------------------"<<endl;[/code]
i done to write } in struct, but still error in blj.hrg and blj.sub
program.cpp:47:70: error: request for member 'hrg' in 'blj', which is of non-class type 'main()::data [30]'
program.cpp:47:89: error: request for member 'sub' in 'blj', which is of non-class type 'main()::data [30]'