Click here to Skip to main content
15,916,692 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Transparent temporaries..? Pin
BadKarma19-Oct-05 9:08
BadKarma19-Oct-05 9:08 
GeneralRe: Transparent temporaries..? Pin
Bob Stanneveld19-Oct-05 10:11
Bob Stanneveld19-Oct-05 10:11 
GeneralRe: Transparent temporaries..? Pin
BadKarma19-Oct-05 20:55
BadKarma19-Oct-05 20:55 
GeneralRe: Transparent temporaries..? Pin
Bob Stanneveld20-Oct-05 0:56
Bob Stanneveld20-Oct-05 0:56 
AnswerRe: Transparent temporaries..? Pin
BadKarma19-Oct-05 23:00
BadKarma19-Oct-05 23:00 
Questionhow to use a class to be a utility class of another class? Pin
knightz10119-Oct-05 6:29
knightz10119-Oct-05 6:29 
AnswerRe: how to use a class to be a utility class of another class? Pin
Maximilien19-Oct-05 6:50
Maximilien19-Oct-05 6:50 
AnswerRe: how to use a class to be a utility class of another class? Pin
Bob Stanneveld19-Oct-05 8:12
Bob Stanneveld19-Oct-05 8:12 
Hello,

If the class has a default constructor, the following approach works:
CSomeClassUtil
{
public:
    static void DoFoo(); // also other utility methods
    // more methods

private:
    static CSomeClass m_Class;
};


This will not work if the class you want to use has a constructor with parameters. The following modifications will have to be made:
CSomeClassUtil
{
public: 
    static void Initialize(/* parameters */)
    {  m_pClass = new CSomeClass( /* parameters */ ); }

    static void DoFoo();

private:
    static CSomeClass* m_pClass; 
};


With this method you have to do some initialization checking to protect yourself from using uninitialized pointers and initializing the same pointer more than once resulting in memory leaks.

If this solution is not what you are looking for, could you explain your goal more clear?

Behind every great black man...
            ... is the police. - Conspiracy brother


Blog[^]
QuestionLooking for scheduling control (Outlook2003 like) Pin
TheDen19-Oct-05 5:32
TheDen19-Oct-05 5:32 
AnswerRe: Looking for scheduling control (Outlook2003 like) Pin
S Douglas20-Oct-05 0:13
professionalS Douglas20-Oct-05 0:13 
QuestionHow to determine hard drives? Pin
wasife19-Oct-05 4:28
wasife19-Oct-05 4:28 
AnswerRe: How to determine hard drives? Pin
David Crow19-Oct-05 4:40
David Crow19-Oct-05 4:40 
AnswerRe: How to determine hard drives? Pin
Anehl19-Oct-05 4:44
Anehl19-Oct-05 4:44 
QuestionSoundcard VU Meter Pin
69 Bay19-Oct-05 2:24
69 Bay19-Oct-05 2:24 
Questionapi subversion Pin
Anehl19-Oct-05 1:45
Anehl19-Oct-05 1:45 
QuestionRe: api subversion Pin
David Crow19-Oct-05 3:15
David Crow19-Oct-05 3:15 
AnswerRe: api subversion Pin
Anehl19-Oct-05 3:36
Anehl19-Oct-05 3:36 
QuestionRe: api subversion Pin
David Crow19-Oct-05 3:39
David Crow19-Oct-05 3:39 
AnswerRe: api subversion Pin
Maximilien19-Oct-05 3:55
Maximilien19-Oct-05 3:55 
GeneralRe: api subversion Pin
David Crow19-Oct-05 4:04
David Crow19-Oct-05 4:04 
AnswerRe: api subversion Pin
Anehl19-Oct-05 3:56
Anehl19-Oct-05 3:56 
GeneralRe: api subversion Pin
Cedric Moonen19-Oct-05 4:02
Cedric Moonen19-Oct-05 4:02 
GeneralRe: api subversion Pin
David Crow19-Oct-05 4:09
David Crow19-Oct-05 4:09 
GeneralRe: api subversion Pin
Anehl19-Oct-05 4:26
Anehl19-Oct-05 4:26 
AnswerRe: api subversion Pin
vikas amin19-Oct-05 4:26
vikas amin19-Oct-05 4:26 

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.