I encounter many times with code where std::vector::clear() of class member of type std::vector is called in constructor and destructor.
I don't see why it's required:
constructor - the class member of type std::vector is empty by default, so no need to call clear().
destructor - the class member of type std::vector will be destroyed...
EDIT: After even more code modification, the error is still there, modified code shown:
KeyDown():
const int input_bit_num = 0x8000;
char keys[256];
bool KeyDown(int key)
{
return (keys[key] & input_bit_num) != 0;
}
PollKeyboard():
LPDIRECTINPUTDEVICE8 di_keyboard;
void PollKeyboard()
{
long result = di_keyboard->GetDeviceSt...
I'm working on a project which needs an embedded DSL to fullfill its expected requirements.
The DSL would be user defined event based. Here goes a mockup of the desired syntax:
user-defined-event-1 {
// event body
}
user-defined-event-2 {
// event body
}
Probably, most similar language I know based on events is LSL (from Sec...
Hi, I am trying to work out how to fade out or dim the Windows Desktop and then display a rectangular portion of the desktop normally. This is for a screen area capture program. You can see the precise effect I am after in Jing Fading the background in a Web page is also commonly done. Any tips/pointers/C++ source much appreciated. Goog...
I am trying to get a double to be a string through stringstream, but it is not working.
std::string MatlabPlotter::getTimeVector( unsigned int xvector_size, double ts ){
std::string tv;
ostringstream ss;
ss << "0:" << ts << ":" << xvector_size;
std::cout << ss.str() << std::endl;
return ss.str();
}
It outputs only...
OK I am not a very experienced C++ programmer, but I was wondering what is the significance of the underscores in the arguments of the following constructor?
class floatCoords
{
public:
floatCoords(float _x, float _y, float _width, float _height)
: x(_x), y(_y), width(_width), height(_height)
{
}
float x, y, width, heigh...
boost::spirit asserts at
boost::spirit::char_class::ascii::isalnum()
when passing ascci characters > 127.
I changed all my private variables from std::string to a
typedef std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >
u_string;
but still boost uses std:.string internally. Wha...
I have to do this for a basic C++ lecture at my university, so just to be clear: i would have used the STL if i was allowed to.
The Problem: I have a class named "shape3d" from which i derived the classes "cube" and "sphere". Now i have to implement "shape3d_stack", which is meant be able of holding objects of the types "cube" and "sphe...
This is concerning Windows XP processes.
I have a process running, let's call it Process1. Process1 creates a new process, Process2 and saves its id.
Now, at some point Process1 wants Process2 to do something, so it first needs to make sure that process2 is still alive and that the user has not not killed it.
How can I check that this...
trying to run this basic form control example on msdn.
At step 1 of the portion "To add a custom property to a control" we place the ClickAnywhere code in the public section of the class.
First error: "error C2144: syntax error : 'bool' should be preceded by ';'"
Is this syntax correct in C++? (see below)
(removing the ClickAny...
Linking my program produces a bunch of errors like below.
/home/starlon/Projects/LCDControl/DrvQt.cpp:8: undefined reference to `Generic<LCDText>::Generic(Json::Value*, int)'
/home/starlon/Projects/LCDControl/DrvQt.cpp:18: undefined reference to `Generic<LCDText>::~Generic()'
/home/starlon/Projects/LCDControl/DrvQt.cpp:8: undefined refe...
I have gone through similar questions on Stackoverflow but still can't get a good answer:
how boost implements signals and slots
How signal and slots are implemented
I am quite puzzled on how this signal/slot is achieved.
Q1: From the following code, sig is connected to two function(Hello() and World()), and it seems that the funct...
I'm working with a low-level API that accepts a char* and numeric value to represent a string and its length, respectively. My code uses std::basic_string and calls into these methods with the appropriate translation. Unfortunately, many of these methods accept string lengths of varying size (i.e. max(unsigned char), max(short), etc......
What benefits do I get from Apache C++ standard library that I don't get from STL implementations that come with the compiler and from Boost libraries?
...
Bounty is for the name of a software package for generating tables and running experiments with particular parameters. That is it!
I am running experiments on computer programs with a number of variables whose effect I am measuring. For each run, I record the time, the precision and the recall.
Are there any frameworks that exist that...
The __FILE__ and __LINE__ macros are built into the C Pre-Processor, and are often used for printing debug output with file names and line numbers. I need something similar, but with just the name of the directory at the end of the path. For instance if my code is in:
/home/davidc/some/path/to/some/code/foo/bar I need a macro that will j...
When I use the following
#include <map>
using namespace LCDControl;
Any reference to the std namespace ends up being associated with the LCDControl name space.
For instance:
Generic.h:249: error: 'map' is not a member of 'LCDControl::std'
How do I get around this? I didn't see anything specific to this on any documentation I look...
Here is a recursive function that I'm trying to create that finds all the subsets passed in an STL set. the two params are an STL set to search for subjects, and a number i >= 0 which specifies how big the subsets should be. If the integer is bigger then the set, return empty subset
I don't think I'm doing this correctly. Sometimes it's...
Is it safe to convert, say, from an unsigned char * to a signed char * (or just a char *?
...
Hello, I am using c++ to look through 256 counts and write the ASCII representative to a file.
If i use the method of generating a 256 character string then write that string to the file, the file weighs 258bytes.
string fileString = "";
//using the counter to attach the ASCII count to the string.
for(int i = 0; i <= 256; i++)
{
file...