Aug 19, 2012 at 8:16pm UTC
Hey all,
This is the class:
class Coogle
{
private:
string s;
public:
Coogle(string s);
~Coogle();
void query(string line) const;
int getNumOfWords() const;
void loadFile(const string filename);
};
how can i use the loadFile(filename) function from the constructor Coogle::Coogle(s){HERE}; , without creating a Coogle class type... ?? is it possible ?
Thank you
Aug 19, 2012 at 9:18pm UTC
A little bit confused by what you're after.
So you want to use the loadFile method without a Coogle class being instantiated?
If that's the case, making it a static
method should work.
Aug 20, 2012 at 2:19am UTC
@iHutch
I think you mean use static for loadFile()
. This is just to point out to maroun that in contrast to C#, one cannot declare a constructor static
.
Aug 20, 2012 at 2:24am UTC
You do realize that by calling at the constructor you are creating an object.
You could use this ->loadFile(s);
or simply loadFile(s);
Aug 20, 2012 at 6:39am UTC
@ToniAz - Yeah, I was referring to loadFile.
Last edited on Aug 20, 2012 at 6:39am UTC