Hi,
I need to make a program that counts the frequency of characters in a file, then outputs how many times each character appears in it. I am trying to make a class for it, but I am having difficulties figuring out how to do the definitions for each method. I need some suggestions on how to get started.
Thank you.
#include <iostream>
#include <fstream>
#include <cctype>
using namespace std;
class charFrequency
{
public:
char getCharacter();
void setCharacter(char character);
long getCount();
void setCount(long count);
void increment();
private:
char character;
long count;
};
int main()
{
charFrequency myCount;
ifstream infile; //input file stream variable
ofstream outfile; //output file stream variable
// check for file
infile.open ("textIn.txt");
if (!infile)
{
cout << "Cannot open the input file." << endl;
return 1;
}
outfile.open("textOut.txt");
myCount.setCount(127);
myCount.setCharacter('A');
myCount.getCount();
myCount.getCharacter();
myCount.increment();
system ("pause");
return 0;
}
char charFrequency::getCharacter()
{
return character;
}
long charFrequency::getCount()
{
}
void charFrequency::setCharacter(char character)
{
}
void charFrequency::setCount(long count)
{
}
void charFrequency::increment()
{
character++;