Function call from class

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
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.
@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.
You do realize that by calling at the constructor you are creating an object.
You could use this->loadFile(s); or simply loadFile(s);
No no no, you're not abiding by the rule of three!
http://en.wikipedia.org/wiki/Rule_of_three_%28C%2B%2B_programming%29

And don't forget to make your destructor virtual if you're using polymorphism.
@ToniAz - Yeah, I was referring to loadFile.
Last edited on
Topic archived. No new replies allowed.