Hi Everyone, I wrote the following program for alternatively incrementing and doubling a counter(increment first) using boost condition variables. Can any one tell me if this is the correct use of boost condition variables. It is working correctly. I don't understand the use of lock in wait function call. What does condition.wait(lock) m...
Hi,
Could anyone tell me why I'm getting error and how to fix it?
QGridLayout* mainLayout = new QGridLayout;
QGridLayout *leftLayout = new QGridLayout;
QGridLayout *rightLayout = new QGridLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);...
I'm trying to learn C++ and right now I'm writing a program that needs to output a list of pairs of integers.
What is the best way to handle this? I don't have the boost library available on our linux computers at school, so I don't believe I can use boost::tuple.
Any suggestions?
...
I'm using the facedetect example and going from there. Right now it only detects faces. Could someone point me in the direction to detect finger tips. Thanks
...
It works just fine, for plain vanilla functions. The code below works just fine. It prints just what is should:
int __cdecl(int, char)
2
int,char
#include <boost/type_traits.hpp>
#include <boost/function.hpp>
#include <boost/typeof/std/utility.hpp>
#include <iostream>
using std::cout;
using std::endl;
int foo(int, char) {
retu...
I have read from the Wikipedia that:
“References cannot be null, whereas pointers can; every reference refers to some object, although it may or may not be valid.”
But I don’t believe because of following code look at it compiler gives no error:
class person
{
public:
virtual void setage()=0;
};
main()
{
person *object=NULL;
perso...
The parameters -S -save-temps work fine, as long as i don't use them on files with the same name.
Think of the following situation: I have a project with a main directory and a subdirectory with the name subDir and in both of the directories are files placed with the name file.c. If I now call gcc -S -save-temps file.cpp subDir/file.c o...
I've got a class (A) that accesses (indirectly via a static method) a static variable (an STL container) in another class (B) in its constructor and destructor.
A objects may be global, global constants, static members of another class, stored in other classes (which may themselves have global or static instances) or basically anywhere ...
I'm working on a C++ DirectX 2D game and I need keyboard and mouse input.
Wikipedia says:
Microsoft recommends that new applications make use of the Windows message loop for keyboard and mouse input instead of DirectInput
So how should I use it?
I have a GameScreen class whice take care of the drawing and the updating(game logic), ...
Hi, I want to check if a string object of 20 characters has only null characters in it (values of zero). My attempt:
string subString;
subString = fileBuffer.substr(origin, origin+20);
if(strCompare.compare("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0") == 0)
cout<<"string is empty"<<endl;
else
cout<<"string is not empty"<<endl;
...
Hi.
I often see the following structure, especially in constructors:
class::class(const string &filename)
{
}
class::class(const char * const filename)
{
}
By step-by-step debug, I found out the 2nd constructor is always called if I pass a hard-coded string.
Any idea:
1) Why the dual structure is used?
2) What is the speed diffe...
Hi, I have three integers (4 bytes of memory for each integer) and I want to assign each of their binary values to a character array with 12 elements. So, if each integer had a value of let's say 2, then I want the character array to have these values:
2 0 0 0 2 0 0 0 2 0 0 0
I have tried:
memcpy(cTemp, &integer1 + &integer2 + &integ...
I'm running a giant simulation / with a graphics engine.
There are lots of events that are flying by.
I would like to timestamp them (measured in milliseconds since the start of program execution).
What should I be using for this? [What library?]
...
When the user grabs a corner of a resizable window, and then moves it, windows first moves the contents of the window around, then issues a WM_SIZE to the window being resized.
Thus, in a dialog where I want to control the movement of various child controls, and I want to eliminate flickering, the user first sees what windows OS thinks ...
What is the best way to convert a std::string to bool? I am calling a function that returns either "0" or "1", and I need a clean solution for turning this into a boolean value.
...
In Java if you wanted all the classes in a namespace you could just do this:
import com.bobdylan.*;
Is there anyway I can get a result similar to:
import boost.*;
(except in C++)
...
GetErrorMessage (from CInternetException) gives me the following:
With the incorrect ftp server name:
"ERROR! The server name or address could not be resolved"
With the incorrect password:
ERROR! The password was not allowed
With the incorrect user name:
ERROR! The password was not allowed <-----? NO separate message for incorrec...
is it possible to re-initialize an object of a class using its constructor?
...
Hi,
I have a question about C++, how to assign a Base object to a Derived object? or how to assign a pointer to a Base object to a pointer to a Derived object?
In the code below, the two lines are wrong. How to correct that?
#include <iostream>
using namespace std;
class A{
public:
int a;
};
class B:public A{
public:
int b;
};...
I am using two large libraries (GUI & network) and I can happily do
using namespace FirstLib;
using namespace SecondLib;
Except for 1 single class called Foobar where names clash.
I my code, I do not use FirstLib::Foobar. Is there a way to say "in my code, whenever you see Foobar, think SecondLib::Foobar ?
...