#include <iostream>
#include <string>//needed to make string array
#include <fstream>//Needed for redaing in from external file
#include <cstdlib>//needed for rand() function (for random word)
#include <ctime>//needed for time() funtion to seed rand()
using namespace std;
/* Sage Balcita
 April 25,2020
 This program will take read in a random word from an external file and use it for a game of hang man */
//class
class Hangman{
public:
    Hangman();//default constuctor
    void setWord(string);
    string getWord();
private:
    string secretWord;
};
void Hangman::setWord(string Word)
{
    ifstream inFile("randwords.txt");
          if(inFile.is_open())
          {
              string wordlist[10];
              for(int i = 0; i < 10; ++i)
              {
                  inFile >> wordlist[i];
              }
              srand(time(0));
                            string secretword = wordlist[rand() % 10];
                            cout<< secretword << endl;
              inFile.close();
          }
}
//void wordPick();
int main()
{
    //wordPick();
    return 0;
}
/*void wordPick()//reads in external file and puts it in an array for a library of words to randomly choose
{
    ifstream inFile("randwords.txt");
       if(inFile.is_open())
       {
           string wordlist[10];
           for(int i = 0; i < 10; ++i)
           {
               inFile >> wordlist[i];
           }
           srand(time(0));
                         string secretword = wordlist[rand() % 10];
                         cout<< secretword << endl;
           inFile.close();
       }
}
*/
so what I'm trying to accomplish is to make a hangman game that uses classes to operate. my problem is that I can't for the life of me understand how to get the function I made to read a random word from an external file to work inside the class. I make a separate function specifically for this that worked by itself but I can't get a class to work for the same thing.
 
    