Click here to Skip to main content
16,004,406 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionAbout File Extension Pin
siddharthsan20-Feb-07 23:38
siddharthsan20-Feb-07 23:38 
AnswerRe: About File Extension Pin
GeeBru21-Feb-07 0:07
GeeBru21-Feb-07 0:07 
AnswerRe: About File Extension Pin
David Crow21-Feb-07 3:26
David Crow21-Feb-07 3:26 
AnswerRe: About File Extension Pin
ThatsAlok21-Feb-07 5:58
ThatsAlok21-Feb-07 5:58 
QuestionAbout file extension Pin
siddharthsan20-Feb-07 23:37
siddharthsan20-Feb-07 23:37 
AnswerRe: About file extension Pin
Garth J Lancaster21-Feb-07 0:09
professionalGarth J Lancaster21-Feb-07 0:09 
AnswerRe: About file extension Pin
ThatsAlok21-Feb-07 5:59
ThatsAlok21-Feb-07 5:59 
QuestionHow make a smart reference expose methods of basetype ? Pin
Mr.Brainley20-Feb-07 23:05
Mr.Brainley20-Feb-07 23:05 
I have written a reference class for one of my classes. It implements reference counting for that class and that's pretty much it. I have written a cast operator to the class type it references, but the compiler does not use that operator implicitly, so whenever i want to access the referenced object, i have to do an explicit cast (or call a method like getObject()). How can i prevent that ?

Here some code to illustrate my problem :

class MyClassReference;

class MyClass
{
public:
    void doStuff();                         //  do that thing you do
    static MyClassReference getInstance();  //  get an instance of the class, but wrapped in
                                            //  my custom reference-class

    ~MyClass();
private:
    friend class MyClassReference();

    MyClass();                              //  private, so you have to use getInstance();

    void addReference();
    void removeRererence();                 //  if (m_referenceCounter == 0) delete this;

    int m_referenceCounter;
};

class MyClassReference
{
public:
    MyClassReference(MyClass &object);  //  call addReference
    //  fancy copy-constructors and assignment-operators here
    operator MyClass &();               //  cast to contained object, not used implicitly

    ~MyClassReference();                //  call removeReference
};


This is just the principle, feel free to comment on it.


wbr

Brainley
AnswerRe: How make a smart reference expose methods of basetype ? Pin
Cedric Moonen20-Feb-07 23:17
Cedric Moonen20-Feb-07 23:17 
GeneralRe: How make a smart reference expose methods of basetype ? [modified] Pin
Mr.Brainley20-Feb-07 23:54
Mr.Brainley20-Feb-07 23:54 
GeneralRe: How make a smart reference expose methods of basetype ? Pin
Cedric Moonen21-Feb-07 0:12
Cedric Moonen21-Feb-07 0:12 
GeneralRe: How make a smart reference expose methods of basetype ? Pin
Mr.Brainley21-Feb-07 0:42
Mr.Brainley21-Feb-07 0:42 
GeneralRe: How make a smart reference expose methods of basetype ? Pin
Cedric Moonen21-Feb-07 0:54
Cedric Moonen21-Feb-07 0:54 
GeneralRe: How make a smart reference expose methods of basetype ? Pin
Mr.Brainley21-Feb-07 1:18
Mr.Brainley21-Feb-07 1:18 
AnswerRe: How make a smart reference expose methods of basetype ? Pin
prasad_som21-Feb-07 1:12
prasad_som21-Feb-07 1:12 
Questionfocus window Pin
rushiraj.jhala20-Feb-07 22:46
rushiraj.jhala20-Feb-07 22:46 
AnswerRe: focus window Pin
prasad_som20-Feb-07 22:53
prasad_som20-Feb-07 22:53 
GeneralRe: focus window Pin
rushiraj.jhala20-Feb-07 23:04
rushiraj.jhala20-Feb-07 23:04 
AnswerRe: focus window Pin
prasad_som20-Feb-07 23:11
prasad_som20-Feb-07 23:11 
GeneralRe: focus window Pin
rushiraj.jhala20-Feb-07 23:15
rushiraj.jhala20-Feb-07 23:15 
AnswerRe: focus window Pin
prasad_som20-Feb-07 23:19
prasad_som20-Feb-07 23:19 
GeneralRe: focus window Pin
rushiraj.jhala20-Feb-07 23:25
rushiraj.jhala20-Feb-07 23:25 
AnswerRe: focus window Pin
prasad_som20-Feb-07 23:51
prasad_som20-Feb-07 23:51 
GeneralRe: focus window Pin
rushiraj.jhala20-Feb-07 23:59
rushiraj.jhala20-Feb-07 23:59 
GeneralRe: focus window Pin
prasad_som21-Feb-07 1:28
prasad_som21-Feb-07 1:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.