Im currently messing around with changing the mouse cursor within a game like C++ application for Windows XP.
To change the cursor I am using SetCursor() and passing in the desired cursor, which is working. However during the while loop in which PeekMessage() is called the cursor keep getting reset back to the default arrow.
This is t...
//can someone with a little time on their hands please compile and run this code and see where I am going wrong. Help! Thanks everyone!
//
#include <iostream>
#include <fstream>
using std::cout;
using std::endl;
using std::ifstream;
using std::ofstream;
using std::ios;
int main()
{
int numbers = 0;
//create and open file
ifstrea...
Does anyone have any idea how to access elements by row, col in OpenCV 2.0's new "Mat" class? The documentation is linked below, but I have not been able to make any sense of it.
http://opencv.willowgarage.com/documentation/cpp/basic%5Fstructures.html#mat
...
Here's what I've got:
void set::operator =(const set& source)
{
if (&source == this)
return;
clear();
set(source);
}
And here's the error I get:
vset.cxx:33: error: declaration of 'source' shadows a parameter
How do I properly do this?
...
I'm wondering if it's an issue with I3D3XFont::DrawTextW, I pass it a string with \t in it, which it expands. However, it doesn't always do it correctly. If I print the same string that I pass to it, the tabs are expanded correctly. For example,
dxfont->DrawTextW(NULL, msg, wcslen(msg), &textbox,
DT_LEFT | DT_TOP | DT_EXPANDTAB...
hi,
I was using C to display a sentence in three lines. The piece of code which worked successfully in VC++ is giving an unexpected output in Borland C++. The ouptut is a charcter array of size n. In the output I could receive more than n characters for the array. How can I avoid this?
...
I read about the static initialization order fiasco in C++ relating to crash of the application. I think I understood it but still have few questions:
1) If I want to reproduce this problem, how can I do it (so that my program should crash)? I would like to write a test program to reproduce a crash. Can you please provide the source code...
Basically im giving a very weak shot at trying to centralize memory management. Anyways, boost::pool uses chunks of certain sizes.
My orignal idea, was to overload new and delete, pass the size into a singleton which would go to the corresponding boost pool and alloc from there.
std::map<size_t, boost::pool<> > m_MemPools;
Anyways it...
We have to automatically create the XML file for an unattended vista/windows 7 installation in which we do write the product key (MAK type). Unfortunately the windows image contains multiple editions (home, home premium, professional, ultimate) so we need to decide which version we should use and write that info to the XML as well. And w...
main .cpp
#include "stdafx.h"
#include "random_generator.h"
int
main ( int argc, char *argv[] )
{
cout.setf(ios::fixed);
base_generator_type base_generator;
int max = pow(10, 2);
distribution_type dist(1, max);
boost::variate_generator<base_generator_type&,
distribution_ty...
I'm inventing interview questions that require analysis of C++ code that does something simple with pointers and recursion. I tried to write strcat() in recursive manner:
size_t mystrlen( const char* str )
{
if( *str == 0 ) {
return 0;
}
return 1 + mystrlen( str + 1 );
}
void mystrcpy( char* to, const char* from )
{...
What is uintptr_t and what it can be used for?
...
I have a portable code running on Visual C++ 2008 and RHEL 5.3 (gcc 4.x.x).
My program should accept command line arguments. I consider using some library for that task.
My candidats are:
Boost program options
ACE has this capability too
(1) is not in standard and as for (2) we already using it heavily for other tasks.
Which is pre...
Hi, I wrote class like this:
#pragma once
#include "stdafx.h"
struct Date
{
private:
int day;
int year;
enum Month {jan = 1,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec};
Month* month;
enum date_state
{
good,err_flag, bad_day, bad_month, bad_year,
};
//I would like to define converting operator from enum to char
Date::date_state::oper...
Hi,
any idea why project dependency (Visual Studio) affects linker settings (C++)? I thought that it's enough to chceck linker settings (Additional depend...) or pragma in source code. It's not a big problem, I'm just curious. Thanks.
...
If I have two rectangles whose positions are deifned using two 2D vectors (i.e. top left, bottom right) how can I check for the points they are intersecting?
...
I'm recently looking for some tools for code coverage, lcov satisfied my needs until I discovered that it doesn't cover dynamic linked code, there are some commercial products but I'd rather stick to free solutions, does somebody know a tool to achieve that?
...
In my code, I receive a const char array like the following:
const char * myString = someFunction();
Now I want to postprocess it as a wchar array since the functions I use afterwards don't handle narrow strings.
What is the easiest way to accomplish this goal?
Eventually MultiByteToWideChar? (However, since it is a narrow string w...
Traditionally, in C++, you would create any dependencies in the constructor and delete them in the destructor.
class A
{
public:
A() { m_b = new B(); }
~A() { delete m_b; }
private:
B* m_b;
};
This technique/pattern of resource acquisition, does it have a common name?
I'm quite sure I've read it somewhere but can't find ...
Hi,
I have the source code for some very simple command line programs. I was considering the option of compiling them on a Linux machine (they were deveoped here) so they can be used on Windows. If I am not wrong this is called Cross-compiling. I have never tried it, but reading yesterday some information, it seems to be kind of complic...