//if the ; is not deleted L5 the code will not compile.
//the error is shown below.
//without the ; the code runs as intended.
//could someone explain why?
//the error is shown below.
//without the ; the code runs as intended.
//could someone explain why?
Code:
#include<iostream> struct Date { int month,day,year; }//; birthdays[ ]={ {12,17,37}, {10,31,38}, {6,24,40}, {11,23,42}, {8,5,44}, }; const Date& getdate(int n) { return birthdays[n-1]; } int main() { int dt=99; while(dt!=0) { std::cout<<std::endl <<"Enter datr #(1-5, 0 to quit):"; std::cin>>dt; if(dt>0 && dt<6){ const Date& bd=getdate(dt); std::cout<<bd.month<<'/' <<bd.day<<'/' <<bd.year<<std::endl; } } return 0; } /* --->> error: expected constructor, destructor, or type conversion before '=' token| Enter datr #(1-5, 0 to quit):3 6/24/40 Enter datr #(1-5, 0 to quit):1 12/17/37 Enter datr #(1-5, 0 to quit):5 8/5/44 Enter datr #(1-5, 0 to quit):0 Process returned 0 (0x0) execution time : 35.750 s Press any key to continue.*/
Comment