Can someone help me please, I am getting this error:
stringdefinition.cpp(7) : error C2448: 'stringClass::wordCount' : function-style initializer appears to be a function definition
When trying to compile this code:
StringHeader.h
#ifndef H_StringHeader
#define H_StringHeader
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int strLength = 51;
char strArray[strLength];
int charAmount;
string line;
int total;
class stringClass
{
public:
int wordCount(string);
};
#endif
StringDefinitions.cpp
#include "StringHeader.H"
int stringClass::wordCount(line)
{
cout << "\nThe String you entered in is: " << strArray << endl;
charAmount = strlen(strArray);
cout << "\nThere are " << charAmount << " characters in your String" << endl;
line = strArray;
int n = count(line.begin(), line.end(), ' ');
cout<<"\nThere are "<< n + 1 <<" words in your String"<<endl;
(n+1) = total;
return total;
}
RunStrings.cpp
#include "StringHeader.H"
int main()
{
stringClass Obj;
cout << "Enter a String" << endl;
cin.getline(strArray, strLength);
line = strArray;
Obj.wordCount(line);
cin.ignore();
return 0;
}