Hi guys, am trying to learn c++... but this code is giving me a strange error..
([Error] name lookup of 'i' changed for ISO 'for' scoping [-fpermissive] )
can some one help me to correct it..
Thanks in advance.. God Bless u all.
for (int i=0; i<=num; i++)
cout<<"Enter dish name and price: ";
cin>>dish[i]>>price[i];
Since the second line is not part of the loop i is undefined.
In pre-standard C++ when initializing a variable in the initialization section of a for(;;) loop the variable was actually initialized as being before the loop. In standard C++ this variable is contained within the loop and goes out of scope at the end of the loop.
Thank u so much.. now its taking inputs.. but calculatebill and showbill function are not working.. After taking inputs, an error occurred, "code.exe has stopped working".. Now Whats wrong?
I think you need to review how classes work. You have created three instances of your class but you only initialize the values in one of these instances (order). All the values in bill and show are uninitialized. You probably only want one instance for this assignment.
I initialized cost=0 and its working fine.
Actually today was my first day to classes and objects.. so silly mistakes happened. but thanks alot. You helped me really patiently.
God bless u. Take care.