Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am programming Conway\'s Game of Life in C++ and I am required to prompt a use

ID: 3753861 • Letter: I

Question

I am programming Conway's Game of Life in C++ and I am required to prompt a user about which grid configuration they want. I am making a class with methods that prompt the user. There is one method I am having trouble invoking in the main.

Here is the code for the method in the CPP file:

char Sim::Prompt(char userEntry)
{
char choice;
//prompt user to ask if they want to insert file or generate random
cout << "Would you like to use a random file or your own?" << endl;
cout << "Enter 'R' for random and 'F' for your own" << endl;
cin >> choice;
return choice;
}

How would I invoke this method in main?

Explanation / Answer

char Sim::Prompt(char userEntry)
{
char choice;
//prompt user to ask if they want to insert file or generate random
cout << "Would you like to use a random file or your own?" << endl;
cout << "Enter 'R' for random and 'F' for your own" << endl;
cin >> choice;
return choice;
}

this is the method of the one class right .

now according to the defination of the method which is

char Sim::Prompt(char userEntry)

that is accept a character means you have to pass a charcter to this function and it will return the character

so this is the class method so if you have to access this method you have to first creates the object of the class

example if your class name is class TEST

then you have to create the objcect of the class TEST in main

like

int main()

{

TEST t1;

}

then call the method t1.Prompt(char userEntry)

since this method will returns the char so you have variable type char to store that returned value

like

char c=t1.Prompt(char userEntry);

in char userEnrty you have to pass some char that is you not define in the question.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote