Why am I getting this error: expected ')' before '&' token?
I'm guessing it has something to do with #includes, but this is my first time trying to use them, so I get a little lost. I was just wondering if someone could tell right away if there was an obvious error.
/** @file Translator.cpp */
#include <fstream>
#include "Translator.h"
#include <vector>
Translator(std::ifstream& fin) //error appears on this line
{
T1(fin);
T1.createTable(fin);
T2(fin);
T2.createTable(fin));
string temp;
while(!fin.eof())
{
fin >> temp;
message.push_back(temp);
}
}
Thank you for your time.
source to share
It's hard to answer this question for sure without seeing the title, but if it's a function, you need to add the return type void
to your function definition:
void Translator(std::ifstream& fin) {
...
}
If it is a constructor, you must provide a qualified name:
Translator::Translator(std::ifstream& fin) {
...
}
source to share
Without a declaration, Translator
it's a bit tricky to say, but if it means being a constructor, then it should be Translator::Translator(std::ifstream& fin)
. If that means it is a method, then it must have the specified return type, so something like void Translator(std::ifstream& fin)
.
source to share