Hello,
I'm trying to delete whole linked list but getting segmentation fault and not able to detect what is the real problem. When I tried debugging using gdb, it is able to remove the first node but throw segmentation fault when deleting second node. Please suggest me what can be the possible reason.
#include <iostream>
using namespac...
Hey, I would like to know the difference between these 2 operator definitions:
1:
class Rational{
//...
public:
//...
Rational operator -() const{ return Rational(-t,b);}
//...
};
2:
class Rational{
//...
public:
//...
friend Rational operator -(const Rational& v) {return Rational(-t,b);}
//...
};
as far as i understand, for the u...
With ActivateKeyboardLayout I am able to change keyboard language to some of the layouts given by GetKeyboardLayoutList. There is one problem though, I can't choose the actual keyboard, only the language. The keyboard I get is simply what the user chose previously for that language. So if I have English US (HKL=0x04090409) and US Dvorak ...
The main view of my application contains a one-level (no children) QTreeView that displays on average 30,000 items. Due to the way the items are created, they are inserted into the model unsorted. This means that on application startup I have to sort the items in the view alphabetically, which takes nearly 1 second, leaving an unresponsi...
In this code:
template<class T>
struct Side
{
};
template<class T>
struct LeftSide : public Side<T>
{
};
template<class T>
struct RightSide : public Side<T>
{
};
Side<int>* f(int left, int right)
{
return left < right ? new LeftSide<int> : new RightSide<int>;//<---Here I'm returning either left or right side
}
int _tmain(int argc...
Hi!
I have implemented operations on a list, one of them is add, and since i don't want to return anything, i read that i had to use **, and it works, but i saw on another place that it is passed as *&, but i don't know the difference
addNode( node *&head, int value)
addNode(node **head, int value)
What is the difference, and which one...
I need to extract all links from html page using regular expressions in C++. Can anybody help me please ?
...
I have a set of bit flags that are used in a program I am porting from C to C++.
To begin...
The flags in my program were previously defined as:
/* Define feature flags for this DCD file */
#define DCD_IS_CHARMM 0x01
#define DCD_HAS_4DIMS 0x02
#define DCD_HAS_EXTRA_BLOCK 0x04
...Now I've gather that #defines for constant...
I guess everyone has run into missing dll's issues from time to time. What I am trying to get is the 'recommended' method to find and install the dll's. Finding out which dll's are missing is easy enough using depends.exe.
...
I extended the Mini XML example from the spirit manual.
The grammar describes a xml tag that can be closed with '/>' and has no child nodes or which is closed like in the example with a closing tag '' and can optionally have children.
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost...
I'm working on an Event based architecture for a research project. The system currently uses Qt signalling, but we are trying to move away from Qt, so I need something that will work almost as well as the Qt event loop and signals across threads.
Probably against my better judgement, I've chosen to use variadic templates to create a gen...
Hey, I'm Trying to make a programa in C++ that generate triangle, square and sine, waves. I enter the frequence, amplitude, etc, and it calculates the average of the wave. And i cah choose what wave generate by selecting a radio button.
This is a real-time system, so, if a wave is being plotted and if I choose a radio buton corresponden...
How are multithreaded game servers written?
If there are 4 threads, is there one thread running the game loop, and 3 accepting and processing requests? Also: is information sent from the thread running the game loop?
...
I want to multiply 2 matrices together. And I only want the diagonal of the result matrix, so I don't want to calculate other elements. I am wondering if there is a function implemented in some existing library, such as cublas or other c++ library.
I know I can do that through a kernel wrapper, and cuda kernel for this is doable. But I...
When it comes to internationalization & Unicode, I'm an idiot American programmer. Here's the deal.
#include <string>
using namespace std;
typedef basic_string<unsigned char> ustring;
int main()
{
static const ustring my_str = "Hello, UTF-8!"; // <== error here
return 0;
}
This emits a not-unexpected complaint:
cannot conv...
The C++ book I'm reading described a sort algo, saying it is the Bubblesort yet I cannot find a single variation of bubblesort just like it. I understand the differences are minor, but is it exactly as efficient as a regular bubblesort ?
BubbleSort(int A[], int length)
for (j=0; j < length-1; j++)
for (i=j+1; i < length; i++)
if (...
Hello!
I was recently interested in how does Microsoft Visual C++ compiler makes and optimizes static variables. I have the following code:
void no_static_initialization() {
static int value = 3;
}
void static_initialization(int new_value) {
static int value = new_value;
}
#include <cstdlib>
int main() {
no_static_initiali...
I'm working on a real-time application (lets call it App1) which is communicating with another application (App2). I used VS2008 and both applications are in C++. Recently I converted the App1 project to VS2010 and right after that it started crashing (I use VS2010 Premium Ver. 10.0.30319.1). Crash dump shows that right before a crash, A...
There is a class like this:
class X {
public:
...
private:
int changeable[3];
int unchangeable[3];
};
And this is its desirable usage:
X x;
x[0] = 1; // here changeable[0] should be used
a = x[0]; // here unchangeable[0] should be used
Is there any way of defining operator[] in class X to imple...
I need to find out if parent of USB device is a hub or host.
Current plan is to use CM_Get_Parent() to get the DEVINST and use SetupDiGetDeviceInfoListDetail() to get the SP_DEVINFO_LIST_DETAIL_DATA structure, but from there I am looking for information to parse against to will tell me if the parent is a hub.
Any pointers/hints/advice w...