I want to implement a function tracer, which would trace how much time a function is taking to execute. I have following class for the same:-
class FuncTracer
{
public:
FuncTracer(LPCTSTR strFuncName_in)
{
m_strFuncName[0] = _T('\0');
if( strFuncName_in ||
_T('\0') != strFuncName_in[0])
{
_...
Is there a way to use each of the arguments in this function in sequence without duplicating code? For example, the first time through the loop I'd like to use R, the next time I'd like to use L, etc. valuestruct is set up in the same order as the arguments, so the button method will return the equivalent bool I need for currentbutton ...
I'm looking for a text editor, much like TextMate (www.macromates.com) on Mac, but I want it to have a built-in compiler.
For example, I do not want an IDE like Visual Studio or Eclipse. I'm looking for an editor where I can click "Run" and it will compile my code and show me the results in a terminal.
I know of a text editor, which ...
I have binary std::string and I need insert it into the BLOB (MySQL) using simple data layer I have. So, I need to execute query: ExecuteSQL((LPTSTR)strQ).
When I am creating this query string (strQ) I cannot add anything to the string after I add this binary string - it just kind if terminated and nothing can be aded. I do not want to u...
Why do we not have a virtual constructor?
...
Of late I'm facing the issues that points finger to VC6 compiler.
Few of them are:
A function-try-block doesn't work. Related Q
in-class constant doesn't work.
__FUNCTION_ (Macro to get function name) doesn't work
The latest addition is it doesn't allow void functions to be passed as part of for_each.
The below example is not compil...
Update 1:
Corrected nonsense code! Thanks for comments, I made a hash of the first snippet, oops.
Update 2:
Also updated question title, as the use of dynamic_cast has been pointed out as not necessary by answers.
What I'm trying to achieve here is a deep copy using strong types; I want to be able to copy Class2 to an...
Could you please let me know what is difference between DECLARE_DYNAMIC and DECLARE_DYNCREATE?
Where exactly we can use them?
...
I got this question when I received a code review comment saying virtual functions need not be inline.
I thought inline virtual functions could come in handy in scenarios where functions are called on objects directly. But the counter-argument came to my mind is -- why would one want to define virtual and then use objects to call metho...
I have a program that uses Microsoft RPC for interprocess communication. When a call of a method with [in, string] parameter like this (MIDL notation):
interface IOurInterface
{
error_status_t rpcMethod( [in, string] const WCHAR* parameter );
}
is invoked it is usually successful. But if the parameter string is long enough (more t...
I have a C++ program that benchmarks various algorithms on input arrays of different length. It looks more or less like this:
# (1)
for k in range(4..20):
# (2)
input = generate 2**k random points
for variant in variants:
benchmark the following call
run variant on input array
# (3)
Is it possible to reset the whole he...
Here's the situation:
Background
I have a mixed mode .NET/Native application developed in Visual Studio 2008.
What I mean by mixed mode is that the front end is written in C++ .NET which calls into a native C++ library. The native code does the bulk of the work in the app, including kicking off new threads as it requires. The .NET co...
I want to get the various user account passwords which are stored in my computer programatically using Visual C++. Are there any APIs to help me do this?
...
I see a lot of people recommending a function/class to be made a friend of another class here in SO though there are other alternatives. Shouldn't friend be sparingly used in C++? I feel other options must be considered before deciding on using the friend feature. Opinions/suggestions are welcome.
...
Hello,
My program is written in C# NET 2.0,it's using external functions from a dll written in C++ using Microsoft Visual Studio 2008 SP1.
If I remove the dll from the directory the program is placed,the program crashes at the moment it should use the dll.That's normal.
But the users that are using my program get the same error at the ...
Bit of a weird one: I was told a while ago by a friend that rearranging this example for loop from :
for(int i = 0; i < constant; ++i) {
// code...
}
to:
for(int i = 0; constant > i; ++i) {
// code...
}
would slightly increase performance in C++. I don't see how comparing a constant value to a variable is faster than vice-...
I am using a lot of STL code with std::for_each, bind, and so on, but I noticed that sometimes STL usage is not good idea.
For example if you have a std::vector and want to do one action on each item of the vector, your first idea is to use this:
std::for_each(vec.begin(), vec.end(), Foo())
and it is elegant and ok, for a while. Bu...
I am planning to write a code library to access some hardware at a low-level (i.e. flipping register bits and such).
Previously, I wrote everything as C functions and used extern "C" to make the library compile for both C and C++ code. So, both C and C++ users merely had to include the header file and call the functions as they were.
...
I'm trying to use gluOrtho2D with glutBitmapCharacter so that I can render text on the screen as well as my 3D objects. However, when I use glOrtho2D, my 3D objects dissapear; I assume this is because I'm not setting the projection back to the OpenGL/GLUT default, but I'm not really sure what that is.
Anyway, this is the function I'm u...
I have a Flash player (flash9.ocx) embedded in an ATL window and have coded functionality into the swf to respond to the return/enter key being pressed.
Works fine from the standalone swf player but as soon as its played from within my embedded player it doesn't execute. It's as if my window is getting in the way somehow?
Is there any wa...