I am having issues with creating my own Toolbar inside the Mainframe. I have bitmaps of buttons which I want to use for my own Toolbar but the problem is that the Toolbar displays inside the View of my SDI application. Here is a pic of the incorrectly displayed Toolbar.
http://www.flickr.com/photos/14402427@N02/3409050475/
Here is the ...
I came across some code that boils down to the following:
enum BAR { /* enum values omitted */ }
class Foo{
public:
void set(const BAR& bar);
private:
uint32_t bits;
};
void Foo::set(const BAR& bar)
{
(uint32_t&)bits = bits | bar;
}
I don't understand the point of the c-style cast in the assignment in Foo::set. Why would you c...
Hi,
using boost::graph with bundled properties. I want to be able to run searches using a variety of different possible edge weighting schemes. I'd like to not create an additional class for the bundled properties if possible, and pass in different weight maps depending on the type of search without creating a new graph or modifying all...
Hi,
I am trying to set up some unit tests for an existing c++ project.
Here's the setup:
I have chosen Google Mock, which includes Google Test. I have added another project (called Tests) to the Visual Studio Solution. The units to test are in another project called Main. The plan is to add each cpp file that I want to test to the Tes...
How to print the bit representation of a string
std::string = "\x80";
void print (std::string &s) {
//How to implement this
}
...
What is your rule for which functions that operate on a class should be member functions vs. nonmember functions?
For example, I have a class which represents a maze using a matrix of bools. I am making a function called isConnected which verifies that 2 points in the maze are in the same region (i.e. it is possible to travel from A to B...
Ok so I've got a QGraphicsScene in a class called eye. I call a function:
void eye::playSequence(int sequenceNum) {
for (int i=0; i<sequences[sequenceNum].numberOfSlides(); i++) {
presentSlide(sequenceNum, i);
time_t start;
time(&start);
bool cont=false;
while (!cont) {
time_t now;
time(&n...
I want to use SQLite as an associative array that is saved to disk.
Is this a good idea? I am worried about having to parse SQL every time I do something like:
database["someindex"] which will have to be translated to something like
select value from db where index = 'someindex' which in turn will have to be translated to the SQL int...
Duplicate of: Is there a reason to call delete in C++ when a program is exiting anyway?
I think we all understand the necessity of delete when reassigning a dynamically-allocated pointer in order to prevent memory leaks. However, I'm curious, to what extent does the C++ mandate the usage of delete? For example, take the following progra...
This is a continuation of Register implementation of a com interface ; only now I've got actual code that needs debugging.
I've got two COM objects, one that implements IAudioSessionEvents and one that implements IClassFactory and produces the first object.
The following code registers those objects (in accordance with my understanding...
Hello,
I am an embedded software developer with about 5+ years of experience working on mobile devices. I recently lost my job and most of the jobs in the embedded field (that I came across) require security clearance and I am not eligible for that. So, for this reason and also just to learn something new, I am planning to move to web d...
I'm trying to print an LPCWSTR value to a file, but it only prints the address, not the value.
I've tried dereferencing the variable (using *) to get the value , but this doesn't work either.
How can I print the value ?
void dump(LPCWSTR text){
ofstream myfile("C:\\myfile.txt", ios::app );
myfile << text << endl;
myfile.close()...
Hi,
Im trying to overload the assignment operator and would like to clear a few things up if thats ok.
I have a non member function, bool operator==( const MyClass& obj1, const myClass& obj2 ) defined oustide of my class.
I cant get at any of my private members for obvious reasons.
So what I think I need to do is to overload the assi...
This may seem frivolous to some of you, but which of the following 2 methods of iteration over a STL container is better? Why?
class Elem;
typedef vector<Elem> ElemVec;
ElemVec elemVec;
// Method 0
for (ElemVec::iterator i = elemVec.begin(); i != elemVec.end(); ++i)
{
Elem& e = *i;
// Do something
}
// Method 1
for (int i = 0;...
Does anyone know why the following generates an error on VC9?
class Elem;
class ElemVec : public vector<Elem>
{
public:
void foo();
};
void ElemVec::foo()
{
BOOST_FOREACH(Elem& elem, *this)
{
// Do something with elem
}
return;
}
The error I get is:
error C2355: 'this' : can only be referenced ins...
This one is for Boost experts. Are there any gotchas or details that the programmer needs to be aware of before he goes in and replaces all his old C/C++ style loops with the lean-and-mean-looking BOOST_FOREACH?
(This question is partly derived from here.)
...
The spate of questions regarding BOOST_FOREACH prompts me to ask users of the Boost library what (if anything) they are doing to prepare their code for portability to the proposed new C++ standard (aka C++0x). For example, do you write code like this if you use shared_ptr:
#ifdef CPPOX
#include <memory>
#else
#include "boost/shared_ptr....
Edit:
For personn interested in a cleaner way to implemenent that, have a look to that answer.
In my job I often need to use third-made API to access remote system.
For instance to create a request and send it to the remote system:
#include "external_lib.h"
void SendRequest(UserRequest user_request)
{
try
{
...
Sometimes I've got warnings with conversion from a longer type to a smaller type e.g.:
void f( unsigned short i ) // f - accept any numeric type
// smaller than std::vector<>::size_type
{}
std::vector < some_type > v;
..
f ( v.size() );
Usually I was using one of next solutions:
assert( v.size() <= std::...
Trying to learn asio, and I'm following the examples from the website.
Why is io_service needed and what does it do exactly? Why do I need to send it to almost every other functions while performing asynchronous operations, why can't it "create" itself after the first "binding".
...