dimanche 23 août 2015

Hiding shared_ptr implementations

I have C++ class defined like this :

namespace glDetail
{

    class CMesh
    {
    public:
        CMesh(const char* fileName);

         /// some more functions...

         CMesh& operator=(const CMesh& other) = delete;
         CMesh(const CMesh& other) = delete; ///note that assignement operators are disabled ! 
         // That is why I need to use shared_ptrs !
    private:
         /// some member vars...
    };
}

typedef shared_ptr<glDetail::CMesh> Mesh;

shared_ptr CreateMesh(const char* fileName){
    make
}

///main.cpp

int main(int argc, char** args){

     Mesh mesh = CreateMesh("someFileName");
     mesh->Render();

}

Would there be a way I could hide this implementation, and Instead of calling CreateXXX call a proper constructor ? (Also calling -> instead of . is confusing...) Like Mesh mesh = Mesh("someFileName");

Aucun commentaire:

Enregistrer un commentaire