c++

Problem with references to pointers

Why this can't compile: // RefToPointers.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using std::cout; class T { public: T(int* value):data_(value) { } int* data_; int* getData_() { return data_; } int getValue()//<----------Here I do n...

(Relatively) Size-Safe Wrapped STL Container in C++

Bear with me because I'm self taught in C++ and am spending my limited extra time on the job to try to learn more about it (I'm a chemical engineering researcher by day). I have a pretty simple objective: 1. Make a size-safe container to store a long list of floats. 2. Make a specialized version of that container that acts as a matri...

Is it legal to declare a friendship with a forward declared class?

I have successfully constructed something similar to the following code in visual studio 2008: class OpDevconfigSession; class DevconfigSession { ... private friend class OpDevconfigSession; }; Again, this works quite well with visual studio. However, if I try to compile the code under g++ version 4.3.2, I get an error message su...

how to pass a value of table to a variable of c++ using select in mysql++

How to select a value from a table and store in a variable in my sql++ e.g select name from employee; write this query in c++ and then store the name in variable e_name ...

C++ Header files, constructor logic, simple get/set methods

Hi, What's the thoughts on allowing simple constructor/method definitions in header files in C++. Some classes I am creating are simple data objects that compose another object say, so they need there own constructor and get/set methods. However these are usually < 3-4 lines each with the constructors using init lists. Is it OK to just...

Problem using mysql++ library

I've read the tutorial at, and I generally get how that works: http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#simple I am trying to build this mysql++ code, and I'm getting an error: std::ostringstream query3; query3<<"select pipe_id from pipe where version_id='"<<id<<"'"; std::storeQueryResult ares=query3.store(); for(...

Data structures for huge graphs in C++

I want to understand how huge graphs can be implemented, so that graph algorithms run faster with huge graphs. ...

how to config apache2 and fastCGI to run my c++ application

Hi. I have written a program with c++ and compiled it with gcc ( like the sample in the fastcgi.com) but i dont know how to run it on localhost. everywhere i searched , i found the php configuration for mod_fcgi which wont work for c++. does any body configured apache and mod_fcgi to run a c++ web application ??? ...

I was trying to select rows using mysql++

Here is my code int main(int argc,char *argv[]) { mysql_init(&mysql); connection = mysql_real_connect(&mysql,.............,"3306",0); if (connection == NULL) { cout << mysql_error(&mysql); return 1; } else { int id=1; mysqlpp::Query query=connection.query("select * from pipe"); //query3<<"select pipe_id from pipe w...

How to use boost::error_info correctly?

I'm trying to following the examples on this page: http://www.boost.org/doc/libs/1_40_0/libs/exception/doc/motivation.html The minute I try the following line: throw file_read_error() << errno_code(errno); I get an error: error C2440: '<function-style-cast>' : cannot convert from 'int' to 'errno_code' How do I get this to work?? ...

Determining the size of the next UDP datagram in system's queue

I want to know the size of the next UDP datagram in the system's queue. I found this question with a similar doubt, but using boost. The last answer (as of 2010/09/23) say something about using getsockopt with the SO_NREAD option in OS X, but I can't find anything about this with Windows (using Winsock). Here I found that I can use ioc...

Pointer alignment in libjpeg

From jmorecfg.h: #define PACK_TWO_PIXELS(l,r) ((r<<16) | l) #define PACK_NEED_ALIGNMENT(ptr) (((int)(ptr))&3) #define WRITE_TWO_PIXELS(addr, pixels) do { \ ((INT16*)(addr))[0] = (pixels); \ ((INT16*)(addr))[1] = (pixels)>>16; \ } while(0) #define WRITE_TWO_ALIGNED_PIXELS(addr, pixels) ((*(INT32*)(a...

Why does C++ not support Variable-length arrays?

Possible Duplicate: Variable length arrays in C++? I am just curious, is there any particular reason why C++ does not allow variable length arrays? ...

MFC CToolBar Help/Link?

I can't find a simple CToolBar example of all things.. I created a toolbar in the resource editor, and loaded the toolbar in my code like this: toolbar = new CToolBar; toolbar->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, CRect(0, 0, 0, 0), AFX_IDW_TOOLBAR); toolbar->LoadToolBar(IDR_TOOLBAR); I have also handl...

How do I initialize a std::set comparator?

I need to initialize some comparator of the new data type TType based on std::set with some object o of another class Object: typedef std::set <unsigned int, sortSet(o)> TType This declaration is otside the class (in header file). At the time of the declaration this object does not have to exist, it will be created later. class sortS...

storing return values then using vs using directly c++

Hey guys, I was writing some code and I found a peculiar error. The function convert_vector2d(&i_scale) converts a string to a vector2d (inherits from sf::vector2f). If you examine the next few lines of code, I am doing the same operation twice. Code: Select all float x = convert_Vector2D(&i_scale).x; float y = convert_Vector2D(&i_scal...

Fundamental typedef operand syntax

Given: typedef type-declaration synonym; I can see how: typedef long unsigned int size_t; declares size_t as a synonym for long unsigned int, however I (know it does but) can't see exactly how: typedef int (*F)(size_t, size_t); declares F as a synonym for pointer to function (size_t, size_t) returning int typedef's two operands...

Sync only parts of a c++ vector using Boost.MPI

I have a std::vector (let's call it "data_vector") that I want to synchronize parts of across processors. I.e., I want to send the values from arbitrary indexes in that vector to other processors. I can easily do this with Boost's send() functions if I want to send the whole vector, but I really only need to send a small portion of it. ...

Using a manifest causes window to remain partially blank

I am in the process of trying to make an app that has most of its development done in Visual C++ 6.0 adhere to Windows theming, or to be precise the visual styles aspect of it. The application in question is a MFC application with the MBCS characterset. Getting theming to kick in in the first place required the InitCommonControlsEx(...);...

Linking error while using Visual Studio 2005(VC8)

I am getting a bunch of linking errors while trying to link the release version of an executable(debug version does not have the same issue). Comparing the command line for the link does not reveal any issues. there are broadly 2 types of errors neither of which I can get a handle on. The first kind complains about a unresolved external...