74
Microsoft Visual C++/CLI Step by Step
2.
Modify the main function as follows, which gives the user the option to break or continue if
desired:
Console::WriteLine("Welcome to your calendar assistant");
for (int count = 1; count <= 5; count++)
{
Console::Write("\nPlease enter date ");
Console::WriteLine(count);
int year = GetYear();
int month = GetMonth();
int day = GetDay(year, month);
Console::Write("Press B (break), C (continue), or ");
Console::Write("anything else to display date ");
String ^input = Console::ReadLine();
if (input->Equals("B"))
{
break;
}
else if (input->Equals("C"))
{
continue;
}
DisplayDate(year, month, day);
}
Note The Equals method is used here to check that two strings contain the same
content. You will see another (and more idiomatic) way to do this using the ==
operator when we discuss operator overloading.
Do'stlaringiz bilan baham: |