I am writing a program where all work is done in the class methods. Main is used to call the methods. I need to know how to get a loop to work without any variables in main that can be used outside the methods.
This is what I have in main:
#include <iostream>
#include <string>
using namespace std;
#include "FerryBoat.h"
int main()
{
//create a constructor for a ferry boat
FerryBoat myBoat('B', 20, 'A');
int unloadVics=0;
char currentPort=' ';
char destPort=' ';
char newPort=' ';
You could have a function defined in your class, which can iterate through your class content. Or have a class including an array of ferryBoat objects as a member: