Anything wrong with this in general?
CallingFunction()
{
CreatePipe()
CreateMutex()
CreateThread( ThreadFunction )
while(there is data left to send)
{
WriteFile(send data in 256 byte chunks)
}
WaitForSingleobject() //don't return until ReadThread is done
return 0;
}
ThreadFunction()
{
WaitForSinglOb...
I have a test fixture class which is currently used by many tests.
#include <gtest/gtest.h>
class MyFixtureTest : public ::testing::Test {
void SetUp() { ... }
};
I would like to create a parameterized test which also uses all that MyFixtureTest has to offer, without needing to change all my existing tests.
How do I do that?
I hav...
i am trying to make a simple call to the pow() function from math.h someihing similar to..
#include<math.h>
int main()
{
float v,w;
w=3.0;
v=pow(w,0.5);//i think this is 'float pow(float,float)'
return 0;
}
but visual studio says its an error
1>c:\users\user\documents\visual studio 2008\projects\deo\deo\main.cpp(7) : ...
Hi,
I'm basically brand new to using Boost. I'm trying to use a ptr_vector to handle some objects that I created.
Specifically I have defined a class Location which defines a particular node on a map (simple 2D game layout). I defined a ptr_vector to hold a set of Locations that have value to the calling function (nodes with units on ...
A while back I learned about the Curiously Recurring Template Pattern (http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern), and it reminded me of a technique I had used to implement an event queue cache.
The basic idea is that we take advantage of a Base class pointer to store a container of homogeneous pointer types. How...
I have some sort of dictionary file that looks like this:
UTM University of Tennessee at Martin
UMD University of Maryland
It is a 3 letters acronym followed by the definition, separated by newlines.
In total the file has 9282 definitions.
My questions are:
1) What would be the best way to store this definitions? Should I place th...
I'm creating a Class.
This class stores user preferences in a Struct.
When creating an instance of the class, I want the client to have the option of creating an instance with no preferences passed in or with a preferences struct passed in.
I can do this with pointers, but I wanted to know how I could do it by passing the preferences...
I was wondering what the easiest way to write a simple form program or web page that will output to a text file that can be opened in excel easily. I know how to write in C++ but I dont know any GUI and I wanted a simple form. I was thinking I could just write an HTML/PHP page but it has to be able to run without the internet, but I dont...
Here's an interesting question about the various quirks of the C++ language. I have a pair of functions, which are supposed to fill an array of points with the corners of a rectangle. There are two overloads for it: one takes a Point[5], the other takes a Point[4]. The 5-point version refers to a closed polygon, whereas the 4-point versi...
I have a problem either adding to or traversing a linked list. The main item class is used by another class but I can add the correct number of these but it looks like when I add more data to the list the app no longer works.
I am not sure exactly where the error is. I know that when I try to traverse the list the application crashes. A...
What's the most interesting wrong view people have on the difference between structure and class in C++?
...
I recently finished fixing a bug in the following function, and the answer surprised me. I have the following function (written as it was before I found the bug):
void Level::getItemsAt(vector<item::Item>& vect, const Point& pt)
{
vector<itemPtr>::iterator it; // itemPtr is a typedef for a std::tr1::shared_ptr<item::Ite...
How do I write a function in C++ that takes a string s and an integer n as input and gives at output a string that has spaces placed every n characters in s?
For example, if the input is s = "abcdefgh" and n = 3 then the output should be "abc def gh"
EDIT:
I could have used loops for this but I am looking for concise and an idiomatic ...
Hi all,
I have a C++ program with a reference-counting smart pointer class. This class works by mapping pointers to reference counts in a static map:
map<ValueIntern*,unsigned int>& ValueRetainMapGetter(){
static map<ValueIntern*,unsigned int> m;
return m;
}
The issue that I've been having is that some static variables which ...
You can consider this a follow-up question to How do I install the OpenSSL C++ library on Ubuntu?
I'm trying to build some code on Ubuntu 10.04 LTS that requires OpenSSL 1.0.0.
Ubuntu 10.04 LTS comes with OpenSSL 0.9.8k:
$ openssl version
OpenSSL 0.9.8k 25 Mar 2009
So after running sudo apt-get install libssl-dev and building, runni...
In http://www.parashift.com/c++-faq-lite/intrinsic-types.html#faq-26.6, it is wriiten that
"Another valid approach would be to define a "byte" as 9 bits, and simulate a char* by two words of memory: the first could point to the 36-bit word, the second could be a bit-offset within that word. In that case, the C++ compiler would need to ad...
I have set the WA_DeleteOnClose widget attribute in a MainWindow.
setAttribute(Qt::WA_DeleteOnClose);
However, whenever I close that main window, I get a segfault in its destructor, which only has delete ui;
In a nutshell, created a Qt4 GUI Application in Creator, added the setAttribute(Qt::WA_DeleteOnClose); to constructor, program ...
hi there,
why doesn't this work:
Snippet 1:
int *a = new int[6];
(*a)[0]=1;
while this is working
Snippet 2:
int myint = 0;
int *ptr =
*ptr=1;
I know that if i use a[0]=1 in snippet 1 it will work. But for me that makes no sense, cos for me it looks that a[0]=1 means: put value 1 to adress a[0]. In other words I put the value...
Hey I am not sure if this has already been asked that way. (I didn´t find anwsers to this specific questions, at least). But:
I have a program, which - at startup - creates an Login-window in a new UI-Thread.
In this window the user can enter data which has to be verified by an server.
Because the window shall still be responsive to th...
Hi,
I have the following function that is used as the glutKeyboardFunc function parameter:
void handleKeypress(unsigned char key, //The key that was pressed
int x, int y) { //The current mouse coordinates
switch (key) {
case 27: //Escape key
exit(0); //Exit the program
}
if (key ...