Dear reader,
I'm working on a aplication where I draw a couple of images, like this:
void TimeSlice::draw(float fX, float fY) {
list<TimeSliceLevel*>::iterator it = levels.begin();
float level_x = x;
float level_y = y;
while(it != levels.end()) {
(*it)->draw(level_x,level_y);
level_y += (*it)->height;
++it;
}
}
Though th...
Hello,
i have an application where is use Qt 4.6 and Microsoft SDKs (the Psapi.Lib).
I use cmake or qmake to build.
For qmake and cmake i specify in hard the path of the Psapi.lib.
qmake :
win32 {
LIBS += "C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\Psapi.Lib"
}
cmake :
SET(PSAPI "C:/Program Files/Microsoft SDKs/Window...
My browse button code is
void CFileOpenDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE);
int result=dlg.DoModal();
if(result==IDOK)
{
path=dlg.GetPathName();
UpdateData(FALSE);
}
}
and this is the code for loading an image from resource but that does not work for loa...
In my C++ application i use an activeX component that runs its own thread (or several I don't know). Sometimes this components throws exceptions. I would like to catch these exceptions and do recovery instead of my entire application crashing. But since I don't have access to its source code or thread I am unsure how it would be done.
T...
This is a simplified example of the problem I have:
#include <stdio.h>
#include <stdlib.h>
void f2(int** a) {
printf("a: %i\n", **a);
}
void f1(int* a) {
f2(&a);
}
int main() {
int a = 3;
f1(&a); // prints "a: 3"
f2(???);
return 0;
}
The problem is that I would like to be able to use f2() both in main() and in f1().
...
Heyo,
My program, which does exactly the same thing every time it runs (moves a point sprite into the distance) will randomly fail with the text on the terminal 'Illegal Instruction'. My googling has found people encountering this when writing assembly which makes sense because assembly throws those kinds of errors.
But why would g...
How does boost::function take a function pointer and get parameters from it? I want wrap a function pointer so that it can be validated before being called. And it would be nice to be able to call it like boost::function is with the () operator and not having to access the function pointer member.
Wrapper func;
func(5); //Yes :...
I have an interface which is used like the following:
if (SUCCEEDED(pInterface->GetSize(&size))
{
wchar_t tmp = new wchar_t[size];
if (SUCCEEDED(pInterface->GetValue(tmp, size)))
{
std::wstring str = tmp;
// do some work which doesn't throw
}
delete[] tmp;
}
Is it safe and portable to do this instea...
Ok, this may be really noobish question, but i am wishing there is something i dont know yet.
I go through a file, and check which string each line has, depending on the string value i execute a different function for it (or functions).
This is how i do it now:
Edit: I need to use variables outside the if-else-if range inside the if's...
I have a fairly complex (approx 200,000 lines of C++ code) application that has decided to crash, although it crashes a little differently on a couple of different systems. The trick is that it doesn't crash or trap out in debugger. It only crashes when the application .EXE is run independently (either the debug EXE or the release EXE - ...
After reading some examples on stackoverflow, and following some of the answers for my previous questions (1), I've eventually come with a "strategy" for this.
I've come to this:
1) Have a declare section in the .h file. Here I will define the data-structure, and the accesing interface. Eg.:
/**
* LIST DECLARATION. (DOUBLE LINKED LI...
is there some way to embed pragma statement in macro with other statements?
I am trying to achieve something like:
#define DEFINE_DELETE_OBJECT(type) \
void delete_ ## type_(int handle); \
void delete_ ## type(int handle); \
#pragma weak de...
Hi guys, at this page:
http://torjo.com/tobias/index.html#boost_utility_singleton._usage I saw that boost has singleton class which gets second param: recreate instance if it's deleted (when we call the singleton). I can't find the implementation of this singleton in boost library. There is only singletons from serialization and pool. Wh...
Using C++ and GCC, can I declare an extern variable that uses a specific address in memory?
Something like
int key __attribute__((__at(0x9000)));
AFAIK this specific option only works on embedded systems. If there is such an option for use on the x86 platform, how can I use it?
...
I've been playing around with references (I'm still having issues in this regard).
1- I would like to know if this is an acceptable code:
int & foo(int &y)
{
return y; // is this wrong?
}
int main()
{
int x = 0;
cout << foo(x) << endl;
foo(x) = 9; // is this wrong?
cout << x << endl;
return 0;
}
2- A...
I saw it was possible to do it but I do not understand the interest.
...
I have a template class with an overloaded + operator. This is working fine when I am adding two ints or two doubles. How do I get it to add and int and a double and return the double?
template <class T>
class TemplateTest
{
private:
T x;
public:
TemplateTest<T> operator+(const TemplateTest<T>& t1)const
{
return TemplateTe...
Further in my code, I check to see check if an object is null/empty. Is there a way to set an object to null?
...
Hello friends,
I have an array of strings..
I want to calculate the MD5 hash of these strings and want to store them in another array using libcrypt.h library in C++ in Linux...
So can anyone tell me how to do it?
give some exapmle or sample code..
...
Hi,
Every C++ books that I've read says something like this:-
All C++ programs have a main() function.
main() function is the starting point for all C++ programs.
All C++ programs begin its execution from the main() function.
However, I found that Windows programs written using MFC do not have any main() function. It use WinMain() f...