Lets say I have some kind of collection an I obtained an iterator for the beginning of it. Now lets say I modified the collection. Can I still use the iterator safely? (regardless of the type of the collection or the iterator)
To avoid confusion , Here is the order of operations I talk about:
Get an iterator of the collection.
Modify ...
Hi,
It's 'my' program. How to close windows after 5 seconds?
//...
DeleteObject (hPedzelOkna);
DeleteObject (hBitmapa);
Sleep(5);
PostQuitMessage (0);
/* The program return-value is 0 - The value that PostQuitMessage() gave */
//...
and
DestroyWindow(hwnd);
not work
(I using Dev C++)
EDIT People have suggested using SetTimer...
In my CPP file I have a call that is:
pt.x = mDownPoint.x + FSign(pt.x-mDownPoint.x) *
FMax( FAbs(pt.x-mDownPoint.x), FAbs(pt.y-mDownPoint.y) );
I get compiler errors for FSign, FMax, FAbs, but I include the header file where they are at.
So I don't see why it would not find it, unless I have done something wrong in the creat...
Possible Duplicates:
Declaring pointers; asterisk on the left or right of the space between the type and name?
what is the difference between const int*, const int * const, int const *
I've been wondering what is the difference between:
float const &var
const float &var
And which one of these is the correct way of writin...
From Effective C++, Item 3
/* case1 */ const std::vector<int>::iterator i // i acts like a T* const
/* case2 */ std::vector<int>::const_iterator ci // ci acts like a const T*
To remember how const applies, I used to remember the following from this article
Basically ‘const’ applies to whatever
is on its immediate left (other t...
Suppose I have some data stored in a container of unique_ptrs:
struct MyData {
int id; // a unique id for this particular instance
data some_data; // arbitrary additional data
};
// ...
std::vector<std::unique_ptr<MyData>> my_data_vec;
The ordering of my_data_vec is important. Suppose now I have another vector of IDs of My...
Hi,
I have a user interface with a tree view on the left, and a viewer on the right (a bit like an email client). The viewer on the right displays the detail of whatever I have selected in the tree on the left.
The user interface has "add", "edit" and "delete" buttons. These buttons act differently depending on what "node" in the tree...
I've created a small tool which is used to process binary files. All the functions involved in reading the files and processing them are templated and are similar to this:
template <class T> void processFile( const char* fileName );
The template parameter T is used to determine the size of data which will be read and treated as one it...
Hey all, I'm working on cleaning up my code from previous semesters.
Previously I created a 151 color swatch library in c++. However because of my time crunch and lack of experience, I created it entirely as a block of define statements. Which, for hard coding values into spots worked fine. However there are some obvious weaknesses to t...
class A{
private:
int a;
public:
A() {a = 4;}
const int& random1() const {return a; }
//int& random2() const {return a; }
const int* random3() const {return &a;}
//int* random4() const {return &a;}
};
int main(){
A objA;
cout<<objA.random1()<<"\n";
cout<<*objA.random3()<<"\n";
}
random2() an...
I've been writing a test case program to demonstrate a problem with a larger program of mine,
and the test case has a bug that the original program does not.
Here's the header file:
// compiled with g++ -I/usr/local/bin/boost_1_43_0 -Wall -std=c++0x -g test.cpp
#include <bitset>
#include <boost/shared_ptr.hpp>
#include <vector>
typed...
Hi all,
I think this is related to C++ linker error than to thrift. I made a change to the thrift file and regenerated cpp & java classes. After this change, I started getting linker errors in cpp. Here is the error
Undefined symbols:
"com::XXXX::thrift::employee::SavingsInfo::operator<(com::XXXX::thrift::employee::SavingsInfo const&...
I have a method that takes an object as an argument.
Both the caller and argument have the same members (they are instances of the same class).
In the method, particular members are compared and then, based on this comparison, one member of the argument object needs to be manipulated :
class Object {
// members
public:
someMet...
Here's an example of a program, where coroutines really help to simplify
the algorithm - imho its hardly possible to implement otherwise.
I also tried to choose a useful task for the demo - this utility converts
a binary file to a sequence of A-Z symbols (and back), without any significant
redundancy, and it has an ability to work with a...
How do I capture key presses when a list view control has focus?
My window creation code looks like
// Window creation
HWND hwnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_APPWINDOW, g_szClassName, "Test", WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 209, 351, 0, 0, hInstance, 0);...
I'm fairly new to C++ (a long time Lisp programmer) and am trying to compile some of the examples for dlib on Windows using MinGW. I added dlib into the PATH. I then call g++ timer_ex.cpp from the examples directory. But I get a lot of error messages.
Short of using Visual Studio, what's the best way of compiling dlib examples on Win...
I'm using list class in c++ and i don't know what does allocator mean here
template < class T, class Allocator = allocator<T> > class list;
if i have list <int> mylist would it mean allocate integer type of memory using the allocator when an element is added to list? and when do you want a custom allocator?
...
I'm trying to wrap my head around getting user input from a joystick/mouse, which doesn't seem all that complicated, but I've run across this simple showstopper: calling joyGetNumDevs() gives me an unresolved external symbol error. I've included the necessary Windows.h and MMSystem.h, so I don't have any idea what may be causing this pro...
Hey, I'm getting a linker error LNK2019: unresolved external symbol when trying to use an overloaded + operator. I'll show you snip-its from the class, and how I'm using it in main. If you need to see more, let me know, I'm just going to try and keep things concise.
/** vec.h **/
#ifndef __VEC_H_
#define __VEC_H_
#include <iostream>
#...
Hi,
I've been trying to write an application, using Qt and mingw32, to download images and set them as the background Wallpaper. I have read several articles online about how to do this, in VB and C#, and to some extent how to do it in c++. I am currently calling the SystemParametersInfo with what seems to be all the correct arguments (...