Solved

What does this code do?

Posted on 2000-02-24
3
180 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

805 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