Solved

What does this code do?

Posted on 2000-02-24
3
181 Views
Last Modified: 2010-04-02

struct CInitTracing
{
      CInitTracing() { CControlPanelApp::bTRACE=TRUE; }
} foo;
0
Comment
Question by:SirSmokeALot
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 2554544
It looks like t turns on tracing to be used when debugging.

when a CInitTracing object is created, its constructor is called.  This constructor sets bTRACE, which must be a static member variable of the CControlPanelApp class, to true.  so in othe words, but creating an object of CInitTracing, you are turning on tracing.  i.e just doing

CInitTracing CIT;

turns on tracing at that point in the program.
0
 

Author Comment

by:SirSmokeALot
ID: 2554698
Cool I thought constructors are only for classes.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2554820
In C++ struct and class are completly the same. except for one insignificant difference.  In a struct, data members and base classes default to public and in a class they default to private.  Since you can overide the default in both struct and in class, they are functionally the same  i.e any class can be written as a struct--you just need to add a "private" or two--and any struct can be witten as a class--you just need to add a "public" or two.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question