array<string, 7> c++ code example

Example: array c++

//dayType.h, the specification file for the class dayType
#include <iostream>
#include <string>
using namespace std;

class dayType{ 
private:
	
	
	string day; // To hold single instance of the name of a weekday.

	const string dayName[7]; // holds the names of the of the seven weekdays
		//"Sunday", "Monday", "Tuesday", "Wedensday", "Thursday", "Friday", "Saturday"

	int dayNumber; // To hold an int representation of the location of a spicific day 
	    //within the array
	
	void setDay(); // Function to set the DayType variable "day" to the name of a 
		//weekday. This function recieves a call from promptUser() and begins by asking 
		//the user to enter the day to set. 
		//Postcondition: after the user enters the information in the form of a 
		//weekday name this function sets the day to that value.
public:

	void promptUser(); // Asks the user if they want to set the day and if yes 
		//prompts the user to set the day by entering the day name via function setDay.
		//Postcondition: If the user chooses to enter Y for yes when prompted this 
		//function calls setDay()

Tags:

Cpp Example