U
utab
Dear all,
I have a class that takes some paths as parameters and does some
operations on the files under these paths. I used Boost filesystem
library for that.
My question is on the construction: Now I am using a list of path
parameters when I create an object of this class but I was thinking to
call a configuration file reader function inside my constructor which
takes care of the initialization of the paths through this function.
Not for calling other functions and operations. If you want to do sth
like this encapsulate this in a function which is also a member of the
class.
This is what I use as the constructor in the header file:
SA(const std::string& pathToVLInStr,const std::string&
pathToVLStartStr,
const std::string& pathToVLOutStr,const std::string&
pathToVLDoneStr,
const std::string& inputStr,const std::string& dmapStr,
const std::string& analysisStr, const std::string&
unixStr):
pathToVLInputFile(pathToVLInStr),pathToVLStartFile(pathToVLStartStr),
pathToVLOutputFile(pathToVLOutStr),pathToVLDoneFile(pathToVLDoneStr),
pathToInputFile(inputStr),pathToDmapFile(dmapStr),
pathToAnalysisFile(analysisStr),pathToVLUnixFile(unixStr){}; // ctor
I need some advice on this. Becasuse in the main file I do not want
to type everything. But is that a good idea to do that from inside the
constructor or in another independent class function?
Best regards,
I have a class that takes some paths as parameters and does some
operations on the files under these paths. I used Boost filesystem
library for that.
My question is on the construction: Now I am using a list of path
parameters when I create an object of this class but I was thinking to
call a configuration file reader function inside my constructor which
takes care of the initialization of the paths through this function.
only be used for the initialization of the data members of the class.From an introductory OOP course, I remember that constructors should
Not for calling other functions and operations. If you want to do sth
like this encapsulate this in a function which is also a member of the
class.
This is what I use as the constructor in the header file:
SA(const std::string& pathToVLInStr,const std::string&
pathToVLStartStr,
const std::string& pathToVLOutStr,const std::string&
pathToVLDoneStr,
const std::string& inputStr,const std::string& dmapStr,
const std::string& analysisStr, const std::string&
unixStr):
pathToVLInputFile(pathToVLInStr),pathToVLStartFile(pathToVLStartStr),
pathToVLOutputFile(pathToVLOutStr),pathToVLDoneFile(pathToVLDoneStr),
pathToInputFile(inputStr),pathToDmapFile(dmapStr),
pathToAnalysisFile(analysisStr),pathToVLUnixFile(unixStr){}; // ctor
I need some advice on this. Becasuse in the main file I do not want
to type everything. But is that a good idea to do that from inside the
constructor or in another independent class function?
Best regards,