Click here to Skip to main content
15,929,210 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHtml Context Help in CView Pin
MikeF_7-Jun-04 7:06
MikeF_7-Jun-04 7:06 
GeneralExpert's opinions pz Pin
peachieboy7-Jun-04 7:06
peachieboy7-Jun-04 7:06 
GeneralRe: Expert's opinions pz Pin
David Crow7-Jun-04 7:14
David Crow7-Jun-04 7:14 
GeneralRe: Expert's opinions pz Pin
Henry miller7-Jun-04 10:00
Henry miller7-Jun-04 10:00 
GeneralClass Question Pin
Tom Wright7-Jun-04 7:01
Tom Wright7-Jun-04 7:01 
GeneralRe: Class Question Pin
David Crow7-Jun-04 7:11
David Crow7-Jun-04 7:11 
GeneralRe: Class Question Pin
Tom Wright7-Jun-04 7:25
Tom Wright7-Jun-04 7:25 
GeneralRe: Class Question Pin
David Crow7-Jun-04 7:43
David Crow7-Jun-04 7:43 
Tom Wright wrote:
This class is a generic class that has no base class to it. It is part of my main app.

Then it is a simple matter of accessing the class' member variable from the main app.

Tom Wright wrote:
So if the class has never been destroyed by my call app...by using the delete function (or goes out of scope)then any data that is in any memory variable in my called class will still reside there...right?

Correct.

Tom Wright wrote:
Can you give an example of when an object is out of scope?

void main( void )
{
    int a; // this variable exists as long as main() does
 
    {
        int *x; // can access both a and x here
        x = new int;
    }
 
    // x no longer exists since it has gone out of scope.  However, the
    // memory that was allocated has not been freed
}


Tom Wright wrote:
And is passing data this way a high risk for memory leaks or buffer overruns?

Memory leaks and buffer overruns can happen in any situation. They are not limited to variables going out of scope. Consider:

class someclass
{
public:
    void somefunction(int *n)
    {
        a = n;
    }
private:
    int *a;
};

void main( void )
{
    someclass sc;

    {
        int x = 5;
        sc.somefunction(&x);
    }

    // at this point, the object sc cannot do anything with its member
    // variable a because the variable x that it pointed to no longer
    // exists
}



"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen


GeneralRe: Class Question Pin
jmkhael7-Jun-04 7:19
jmkhael7-Jun-04 7:19 
GeneralRe: Class Question Pin
Tom Wright7-Jun-04 7:54
Tom Wright7-Jun-04 7:54 
GeneralRe: Class Question Pin
David Crow7-Jun-04 9:04
David Crow7-Jun-04 9:04 
GeneralGetting what's been clicked on a listbox Pin
kfaday7-Jun-04 6:33
kfaday7-Jun-04 6:33 
GeneralRe: Getting what's been clicked on a listbox Pin
David Crow7-Jun-04 7:08
David Crow7-Jun-04 7:08 
GeneralRe: Getting what's been clicked on a listbox Pin
kfaday7-Jun-04 8:34
kfaday7-Jun-04 8:34 
GeneralCreate and Modify a CHM file Pin
Tcpip20057-Jun-04 6:23
Tcpip20057-Jun-04 6:23 
GeneralRe: Create and Modify a CHM file Pin
Ravi Bhavnani7-Jun-04 7:30
professionalRavi Bhavnani7-Jun-04 7:30 
GeneralClicking on a bitmap Pin
kfaday7-Jun-04 6:08
kfaday7-Jun-04 6:08 
GeneralRe: Clicking on a bitmap Pin
Johan Rosengren7-Jun-04 6:13
Johan Rosengren7-Jun-04 6:13 
GeneralRe: Clicking on a bitmap Pin
kfaday7-Jun-04 6:15
kfaday7-Jun-04 6:15 
GeneralRe: Clicking on a bitmap Pin
Johan Rosengren7-Jun-04 6:29
Johan Rosengren7-Jun-04 6:29 
GeneralRe: Clicking on a bitmap Pin
kfaday7-Jun-04 6:37
kfaday7-Jun-04 6:37 
QuestionHow to create reset button Pin
syasya7-Jun-04 5:59
syasya7-Jun-04 5:59 
AnswerRe: How to create reset button Pin
Johan Rosengren7-Jun-04 6:15
Johan Rosengren7-Jun-04 6:15 
GeneralProblem with Threads dialog box Pin
LasVegasGuy7-Jun-04 5:29
LasVegasGuy7-Jun-04 5:29 
Generalserial com port transmission Pin
jetournier7-Jun-04 5:27
jetournier7-Jun-04 5:27 

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.