I need to profile a program to see whether any changes need to be made regarding performance. I suspect there is a need, but measuring first is the way to go. This is not that program, but it illustrates the problem I'm having:
#include <stdio.h>
int main (int argc, char** argv)
{
FILE* fp = fopen ("trivial.c", "r");
if (fp)
{
...
I'm using C++ templates to pass in Strategy functors to change my function's behavior. It works fine. The functor I pass is a stateless class with no storage and it just overloads the () operator in the classic functor way.
template <typename Operation> int foo(int a)
{
int b=Operation()(a);
/* use b here, etc */
}
I do this often, a...
I trying to incorporate a simple error logging into my existing app, at the moment it reports errors just using cout so i was hoping to keep a similar interface using the << operator. However i want it to log the line & function the error occurred. But i don't want to have to type __LINE__, __FUNCTION__ every time i need to log. Does any...
I have a class with a static method that looks roughly like:
class X {
static float getFloat(MyBase& obj) {
return obj.value(); // MyBase::value() is virtual
}
};
I'm calling it with an instance of MyDerived which subclasses MyBase:
MyDerived d;
float f = X::getFloat(d);
If I link the obj file containing X into my ...
Background
I have a project named PersonLibrary which has two files.
Person.h
Person.cpp
This library produces a static library file. Another project is TestProject which uses the PersonLibrary (Added though project dependencies in VS008). Everything worked fine until I added a non-member function to Person.h. Person.h looks like
c...
Saludos a todos en stackoverflow.com!!
So... I'm a C++ newbie currently taking the subject of Data Structures, and I want to consult something with you guys:
Since I started studying Systems Engineering, I've been using the last version of Dev-C++ for all my programming projects. It has done it's job well so far, but it has a FATAL fla...
Hello all,
on linux, gcc 4.3, compiling a class with boost::thread implementation and mutexes / condition variables I get the following strange error, apparently due to type conflicts with the posix thread library:
*Compiling: filter.cpp
/usr/include/boost/thread/condition.hpp: In member function »void boost::condition::wait(L&) [with ...
So now I can make a .exe of my application. Now how do I get my application ready to deploy for windows?
...
Im learning C++ and i made a New program and i deleted some of the code and now my console window will not hide is there a way to make it hide on startup without them seeing it
...
Hey,
I've been talking with friends and some completely agree that templates in C++ should be used, others disagree entirely.
Some of the good things are:
They are more safe to use (type safety).
They are a good way of doing generalizations for APIs.
What other good things can you tell me about C++ templates?
What bad things can y...
Every program does have the scrollbar above the status bar. Right? Well, not mine.
When i tried to set up my own scroll bars in my program, i suprisingly made them work! So did i manage to get the status bar work too! Hurray! :-) ...But the status bar is ABOVE the scroll bar, when it should be UNDER the scroll bar. How do i move the scr...
Currently, SDL_Mixer has two types of sound resources: chunks and music.
Apart from the API and supported formats limitations, are there any reasons not to load and play music as a SDL_Chunk and channel? (memory, speed, etc.)
...
Not as in "can't find the answer on stackoverflow", but as in "can't see what I'm doing wrong", big difference!
Anywho, the code is attached below. What it does is fairly basic, it takes in a user created text file, and spits out one that has been encrypted. In this case, the user tells it how many junk characters to put between each ...
I was thinking about writing an app (in either C++ or C#) to help me sort videos faster and I was wondering: How can I open more then 2 (maybe more) instance of VLC and control them though my EXE? What are my options? I know I can SendMessage to the EXE directly. Could I do something like simulate user keys?
How do I open the VLC exe...
I decided to leave my windows install behind and am now running Debian as my default OS. I have always coded in Windows and specifically with Visual Studio. I am currently trying to get used to compiling my code under linux.
Although I still have a lot of documentation to read, and don't expect you guys to make it too easy for me, it'd ...
Why was Google's Chrome browser written almost entirely in C++ and not C# or Java?
...
Hello, I am creating a simple 2D OpenGL application but I seem to be experiencing some camera issues. When I draw a rectangle at (20,20) it is drawn at (25,20) or so. When I draw it at (100, 20) it is drawn at 125 or so. For some reasons everything is being shifted to the right by a few %.
I have pasted a trimmed down version here
http:...
Hello, I have tried to use NUnit to test C# code the is already connected to C++ code (without the NUnit the application work perfectly).
In my test I run the main function through AppDomain.CurrentDomain.ExecuteAssembly(..), However when the C# code tries to "communicate" with the C++ it throws an exception and the test crashes. The ex...
By already given specific process' handle, how can I move further to search for a specific keywords(bytes, ints(2 bytes), text(an array)) in its memory in code, using VC++ ?
...
I was trying this piece of code to check whether the divide by zero exception is being caught:
int main(int argc, char* argv[])
{
try
{
//Divide by zero
int k = 0;
int j = 8/k;
}
catch (...)
{
std::cout<<"Caught exception\n";
}
return 0;
}
When I complied this using VC6, the catch handl...