I have a loop
for(aI = antiviral_data.begin(); aI != antiviral_data.end();)
{
for(vI = viral_data.begin(); vI != viral_data.end();)
{
if((*aI)->x == (*vI)->x && (*aI)->y == (*vI)->y)
{
vI = viral_data.erase(vI);
aI = antiviral_data.erase(aI);
}
else
{
vI++;
aI++;
}
}
}
But when ever antiviral_data contains a...
I'm trying to get eclipse to work with MinGW.
I've done the following:
Downloaded CDT for eclipse.
Installed MinGW.
Added C:\MinGW\bin to my path.
Opening a command prompt (CMD) and typing g++ or alike works fine.
I run eclipse, create a "New C++ Project", and only get the option saying "other toolchains".
There's a MILLION tutorials...
Why is it better to use '!=" than '<' in a vector loop? I just can't see the difference.
...
How would I load certain images into an array set like
Map = ( ( 1, 1, 1 ), ( 2, 2, 2 ), ( 3, 3, 3 ) )
I can put
images into variables like so
one = oslLoadImageFile("one.png", OSL_IN_RAM, OSL_PF_5551);
so whould I be able to do something like Map = ( ( one, one, one ) )
and if each image was 32x32 would it be able to be side by ...
when ever a function has a object passed by value it uses either copy constructor or bit wise copy to create a temporary to place on stack to use inside the function,How about some object returned from function ?
//just a sample code to support the qn
rnObj somefunction()
{
return rnObj();
}
and also explain how the return value is ta...
I'm trying to write a simple GUI application using Qt framework.
The purpose of this app is to retrieve data from my isp and parse them for presentation.
How do i authenticate my user/password with the webserver and retrieve the html page in question?
Are there any utility libs that make this task trivial?
I figure i need to interac...
When i try to
$ make depend -f gcc.mak
a middleware on my Ubuntu machine I get this
/usr/include/../include/limits.h:125:26: error: no include path in which to search for limits.h
This is the contents around limits.h:125:
/* Get the compiler's limits.h, which defines almost all the ISO constants.
We put this #include_next outs...
I'm playing around with Box2D for fun right now, and after getting the hang of some of the concepts I decided to make my own test for the test bed (Box2D comes with a set of examples and has a simple extendable Test class for making your own tests). I started by grabbing one of the other tests, ripping out everything but the function sig...
Here's a constructor for my Game class:
// Construct a Game to be played with player on a copy of the board b.
Game(const Board& b, Player* player)
{
...
}
Here's how I'm using the constructor:
Player p("Player Name");
Board b(6,3);
Game g(b, &p);
How does this work? Is b being copied?
If I want to save a pointer to player, shou...
Hello all :)
Working on an algorithm to look at a STL container of STL strings (or other strings, making it general)
Basically it loops through something like a std::list and returns the length of the longest beginning in common. It's for processing lists of files, like this:
C:\Windows\System32\Stuff.exe
C:\Windows\Things\InHere.txt...
I have 2 static objects in 2 different dlls:
An object Resources (which is a singleton), and an object User. Object User in its destructor has to access object Resources.
How can I force object Resources not to be destructed before object User?
...
Hello all :)
I need to get a reference to an iterator of a reference. However, my compiler is choking on this code:
template <typename InputIterator> size_t iLongestBegin(InputIterator first, InputIterator last)
{
typedef typename std::iterator_traits<InputIterator>::reference SequenceT;
//Problem is next line
typedef t...
Hi.
I´m pretty new to programming in C++ and I´m using pthreads. I´m cross compiling my code for OpenWRT but for some reason I get segmentation fault when I run the program on my board but it runs fine on my PC. I suspect that the error occurs in the linking stage of the compilation because I tried a small C program and that worked fine...
I'm buiding an API that allows me to fetch strings in various encodings, including utf8, utf16, utf32 and wchar_t (that may be utf32 or utf16 according to OS).
New C++ standard had introduced new types char16_t and char32_t that do not have this sizeof ambiguity and should be used in future, so I would like to support them as well, but...
I am currently working on a program that read each line from a file and extract the word from the line using specific delimiter.
So basically my code looks like this
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argv, char **argc)
{
ifstream fin(argc[1]);
char delimiter[] = "|,.\n ";
...
struct InkPen
{
void Write()
{
this->WriteImplementation();
}
void WriteImplementation()
{
std::cout << "Writing using a inkpen" << std::endl;
}
};
struct BoldPen
{
void Write()
{
std::cout << "Writing using a boldpen" << std::endl;
}
};
template<class PenType>
class Writer : public PenType
{
public:
v...
I've found that WH_MOUSE is not always called. Could the problem be that I'm using WH_MOUSE and not WH_MOUSE_LL?
The code:
class MouseHook
{
public:
static signal<void(UINT, const MOUSEHOOKSTRUCT&)> clickEvent;
static bool install()
{
if (isInstalled()) return true;
hook = ::SetWindowsHookEx(WH_MOUSE, (HOOKPROC)&mousePr...
I've been having big problems in reproducing and finding the cause of a bug. The occurence seems entirely random, so I suspected an uninitialized variable somewhere. But then I found this piece of code:
CMyClass obj; // A
obj.DoStuff();
if ( somebool )
{
CMyClass obj; // B
obj.DoStuff();
}
obj.DoOtherStuff();
It seems as tho...
How do I exit a while loop immediately without going to the end of the block?
e.g.
while(choice!=99)
{
cin>>choice;
if (choice==99)
//exit here and don't get additional input
cin>>gNum;
}
any ideas?
...
I use the DeleteFile and CopyFile methods. Do these functions throw exceptions or just set errno and lastError? Do I need to surround this code with try and catch?
...