mercredi 2 novembre 2016

Usage of extern & inline

In my C++ code, I have a definition like that;

class A {
    int i;
public:
    void setI(int temp) {
        i = temp;
    }
};

extern A* a;

After that I have a function which fills the variable of a with some stream obtained from arguments.

inline void Func() {
    ... // Stream definition with ifstream etc.
    int k;
    stream >> k;
    a->setI(k);    // Gives segmentation fault...
}

What can be the reason? Thanks in advance...

Aucun commentaire:

Enregistrer un commentaire