**the first constructor is supposed to take words from a txt file and the second one takes words from the string and add it to fileVec vector.
i'm trying to call a parameterized constructor but it doesn't work, instead it calls the default constructor **
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
using namespace std;
class stringSet
{
private:
int i = 0;
string fileName, line, word, word2;
istringstream iss;
fstream file;
vector<string> fileVec;
public:
string str = "that's a string for parameterized constructor";
stringSet()
{
cout << "Please enter filename: ";
getline(std::cin, fileName);
fileName += ".txt";
file.open(fileName, ios::in);
if (file.is_open())
{
while (getline(file, line))
{
iss.clear();
iss.str(line);
while (iss.good())
{
iss >> word;
fileVec.push_back(word);
cout << fileVec[i] << endl;
i++;
}
}
}
}
stringSet(string str)
{
istringstream iss2(str);
while (iss2 >> word2)
fileVec.push_back(word2);
cout << fileVec[i] << endl;
i++;
}
};
int main()
{
// stringSet();
stringSet(str);
return 0;
}
that code calls stringSet() instead of stringSet(str)