c++

g_signal_connect error invalid use of member

Hi Guys, More GTK questions, im trying to compile some code and im getting the following error: error: invalid use of member (did you forget the ‘&’ ?) This is comming from the g_signal_connect call: g_signal_connect ((gpointer) Drawing_Area_CPU, "expose-event", G_CALLBACK (graph_expose), NULL); Drawing_Area_CPU is a GtkW...

Vector Troubles in C++

I am currently working on a project that deals with a vector of objects of a People class. The program compiles and runs just fine, but when I use the debugger it dies when trying to do anything with the PersonWrangler object. I currently have 3 different classes, one for the person, a personwrangler which handles all of the people colle...

How do I build a filtered_streambuf based on basic_streambuf?

I have a project that requires me to insert a filter into a stream so that outgoing data will be modified according to the filter. After some research, it seems that what I want to do is create a filtered_streambuf like this: template <class StreamBuf> class filtered_streambuf: public StreamBuf { ... } And then insert a filtered_strea...

How to restart Linux from inside a C++ program?

I have a Qt 4 GUI where I need to have a option in a drop-down menu that allows the user to choose to restart the computer. I realize this might seem redunant with the ability to restart the computer in other ways, but the choice needs to stay there. I've tried using system() to call the following: a suid-root shell script a non-suid s...

Given an ELF binary built from C++ with gcc, how can I determine the sizeof some type in it?

Is there some way using binutils tools to get this? For example: // x.cc typedef long long MyInt; int main(int argc, char* argv[]) { // blah blah blah } Then: g++ -g x.cc -o a.out How can I analyze a.out to get sizeof(MyInt)? GDB can do it, but I don't want to use GDB because it's really slow for large binaries. ...

Overly blurred image? Need to avoid processing already blurred portions of it.

I have this function semi-working, but it seems that the image that comes out is overly-blurred. this is because it is processing already blurred portions, I imagine? I was told I need to write it to a new image, but I can't figure out how to create that. When I was using the Image tempImage constructor, I was getting errors of segmenta...

Why are there defined constants and declared constants in CPP?

Why are there two ways to "declare" constants in CPP? Which is better, or should I write, which of them should I use when? #define MYCON 100 const int MYCON=100 ...

c++ queue template

ALright, pardon my messy code please. Below is my queue class. #include <iostream> using namespace std; #ifndef QUEUE #define QUEUE /*---------------------------------------------------------------------------- Student Class # Methods # Student() // default constructor Student(string, int) // constructor display() ...

Fonts in a multi-platform environment

What is the best way to deal with fonts in a multi-platform distributed system? If I want to use a common font across all systems to show to the user, what's the best way to do this. From the little I've been reading each platform looks to have fonts that are of the same family (ie serif, sans-serif) but with different names. CSS look...

get error when i try to open file using specific path

i get errors when i try to open a file using the file path out_stream5.open("C:pathshowitems.txt", ios::out); warning C4129: 'o' : unrecognized character escape sequence error C2100: illegal indirection ...

Legacy C++ project using Makefile ..moving to Eclipse IDE?

I have a legacy C++ project on Linux which uses the typical: ./configure make make install to build and install. I would really like to build it instead with an IDE like Eclipse. Is this doable? Is there something in Eclipse that can parse the original Makefile(s) and turn it into an Eclipse project? ...

K/APL style programming in C++?

I'm writing code in C++, but I really like K/APL's array-oriented style. Does anyone know of a good set of operator overloading tricks / macros / ... to allow some K/APL -style programming in C++? Thanks! ...

Have macro 'return' a value

I'm using a macro and I think it works fine - #define CStrNullLastNL(str) {char* nl=strrchr(str,'\n'); if(nl){*nl=0;}} So it works to zero out the last newline in a string, really its used to chop off the linebreak when it gets left on by fgets. So, I'm wondering if I can "return" a value from the macro, so it can be called like f...

Simple matrix example using C++ template class

I am trying to write a trivial Matrix class, using C++ templates in an attempt to brush up my C++, and also to explain something to a fellow coder. This is what I have som far: template class<T> class Matrix { public: Matrix(const unsigned int rows, const unsigned int cols); Matrix(const Matrix& m); Matrix& operator=(const ...

Constructor Type Coercion in C++

Take the following class: class mytype { double num; public: mytype(int a) { num = sqrt(a); } void print() { cout << num; } } Say there is a method which takes a mytype: void foo(mytype a) { a.print(); } Is it legal c++ (or is there a way to implemen...

mmap() for large file I/O?

I'm creating a utility in C++ to be run on Linux which can convert videos to a proprietary format. The video frames are very large (up to 16 megapixels), and we need to be able to seek directly to exact frame numbers, so our file format uses libz to compress each frame individually, and append the compressed data onto a file. Once all fr...

C++0x optimizing compiler quality

hello. I do some heavy numbercrunching and for me floating-point performance is very important. I like performance of Intel compiler very much and quite content with quality of assembly it produces. I am thinking at some point to try C++0x mainly for sugar parts, like auto, initializer list, etc, but also lambdas. at this point I use ...

visual studio 2005 to 2010 with boost

About a month a go I spent almost an entire week trying to figure out how to build the boost libraries for vs2005 and today I updated to vs2010. Do I need to remove boost for vs 2005(I uninstalled vs2005) and go through the build process for 2010 or will it magically work and I can go take a nap? ...

C++ 'ClassName Not Declared' Error

I have this cpp file. dsets.cpp: #ifndef DSETS_CPP #define DSET_CPP //Adds elements to the DisjointSet data structure. This function adds //x unconnected roots to the end of the array. void DisjointSets::addelements(int x){ } //Given an int this function finds the root associated with that node. int DisjointS...

Getting window style

I'm trying to check if a window has a certain style using GetWindowLong(hWnd, GWL_STYLE) but that gives me a LONG type of variable. how would you check for a specific style from that say a const value type 'WS_CAPTION'? ...