I'm writing a thread-pool for Qt as QRunnable doesn't handle event loops in new threads.
Not too familiar with STL, what would be the best way to pop() something by priority? Priority should probably be a property of MyRunnable imo, but I can always give that info to an STL container when adding the runnable to the queue.
...
I'm trying to read encrypted struct data from file using fread(). once i get the decrypted struct bytes, I'd like to it put them back into this struct.
struct data
{
std::string s1;
std::string s2;
std::string s3;
LONG l;
};
how would you convert a struct into bytes which can be reconstructed from bytes?
...
I cannot find how I'm supposed to handle file opening in my program. For example if the user does Open With ... myprogram.exe then how do I handle that and do something with it. which WM_Message is sent?
Thanks
*no I mean if you have sometext.txt and openwith Notepad.exe, it magically displays the text, so how can I know if someone used...
I'm writing a custom iterator for a Matrix class, and I want to implement the increment method, which gets called when the iterator is incremented:
void MatrixIterator::increment()
{
// go to the next element
}
Suppose the iterator has been incremented too many times and now points to past the end of the matrix (i.e. past the one-...
Good afternoon,
I have been working on a dll that can use CORBA to communicate to an application that is network aware. The code works fine if I run it as a C++ console application. However, I have gotten stuck on exporting the methods as a dll. The methods seems to export fine, and if I call a method with no parameters then it works...
I have this silly argument with a friend and need an authoritative word on it.
I have these two snippet and want to know which one is faster ? [A or B]
(assuming that compiler does not optimize anything)
[A]
if ( foo () );
[B]
int t = foo ();
if ( t )
EDIT : Guys, this might look a silly question to you but I have a hardware ...
Hello
I have the following code implemented on C++(Linux) to check on my listening socket and stdin using select. select however keeps returning -1 no matter what I try to do! What's wrong with that code :s I will appreciate any help. Thanks
highsock = m_sock; //listening socket
memset((char *) &connectlist, 0, sizeof(connectlist));
m...
OK, I'm going to try my best to explain my problem. I have this program where you can select 5 balls. When you select one, you can drag it while you have the mouse button pressed and the cursor is within the ball's radius.
The problem is that I need a way to make the ball go up when the user stop pressing the mouse button, like he sent ...
I'm making a notepad-like program. To get the text from a file I read each character into the buffer by doing
while (!file.EOF())
{
mystr += file.get();
}
however if I load in an exe it stops after MZ but Notepad reads the whole exe.
I set my ifstream to binary mode but still no luck. What am I doing wrong?
Thanks
code:
(messy)
vo...
Had the following as an interview question a while ago and choked so bad on basic syntax that I failed to advance (once the adrenalin kicks in, coding goes out the window.)
Given a list of string, return a list of sets of strings that are anagrams of the input set. i.e. "dog","god", "foo" should return {"dog","god"}. Afterward, I crea...
Hello,
I'm developing what it's turning into a "cross-platform" 2D Game Engine, my initial platform target is iPhone OS, but could move on to Android or even some console like the PSP, or Nintendo DS, I want to keep my options open.
My engine is developed in C++, and have been reading a lot about Box2D and Chipmunk but still I can't d...
Suppose I have a rather large class Matrix, and I've overloaded operator== to check for equality like so:
bool operator==(Matrix &a, Matrix &b);
Of course I'm passing the Matrix objects by reference because they are so large.
Now i have a method Matrix::inverse() that returns a new Matrix object. Now I want to use the inverse directl...
I am developing game editor in c++.I have implemented reflection mechanism using DiaSDK.Now I want to store state of the objects(Like Camera,Lights,Static mesh) in some level file via serialization.
And later on able to retrieve their state via deserialization.Serializing objects is not a problem for me.During deserialization I am gettin...
Hello,
this is an implementation of length indicator field
but it hang and i think stuck at a loop and don't show any thing.
// readx22.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "stdio.h"
using namespace std;
class Student
{
public:
string id;
...
Suppose i have:
class A
{
A(A& foo){ ..... }
A& operator=(const A& p) { }
}
...
A lol;
...
A wow(...)
{
return lol;
}
...
...
A stick;
stick = wow(...);
Then I'll get a compile error in the last line. But if I add 'const' before 'A&', its ok.
I want to know why. Where it's exactly the problem?
I dont get why it shoul...
I'm trying to create a class which contains a static pointer to an instance of itself. Here's an example:
A.h:
#include <iostream>
#ifndef _A_H
#define _A_H
class A {
static A * a;
};
A * a = NULL;
#endif
However, when I include A.h in another file, such as:
#include "A.h"
class B {
};
I get the following error:
ld: dupli...
I'd like to write a simple ostream which wraps an argument ostream and changes the stream in some way before passing it on to the argument stream. The transformation is something simple like changing a letter or erasing a word
What would a simple class inheriting from ostream look like? What methods should I override?
...
To begin, I am trying to write a run-of-the-mill, simple Ray Tracer. In my Ray Tracer, I have multiple types of geometries in the world, all derived from a base class called "SceneObject". I've included the header for it here.
/**
Interface for all objects that will appear in a scene
*/
class SceneObject
{
public:
mat4 M, M_inv;
Col...
In the program below, is the line
Derived(double y): Base(), y_(y)
correct/allowed? That is, does it follow ANSI rules?
#include <iostream>
class Base
{
public:
Base(): x_(0)
{
std::cout << "Base default constructor called" << std::endl;
}
Base(int x): x_(x)
{
std::cout << "Base constructor called with x = " << x...
I need to use Loki's small object allocator but I am very confused as to how it works. I've read the documentation and lots of forums but it doesnt make sense: some of them say to use the stl, others use custom allocators. I just need to be able to test its performance with allocating and deallocating objects of different sizes. Could so...