c++

How to change source path in executable g++

I compile my programs in a compiler machine. Later I run and test the programs in a different environment. If I compile with -fprofile-arcs on then the program tries to write a file in a folder which does not exist in the running environment. Is there a work-around for this problem? Thanks ...

Creating internal and external interfaces for a class / information hiding

For some classes of a static C++ library I want to offer different interfaces for the user of the library and for the library itself. An example: class Algorithm { public: // method for the user of the library void compute(const Data& data, Result& result) const; // method that I use only from other classes of the lib...

Can I extract struct or public class members using a template?

Basically, I have lots of differently typed structs like this: typedef struct { char memberA; int memberB; ... } tStructA; Is it possible to use a template to get/extract an arbitrary member from the struct? In pseudocode, I'm looking for something like this: /*This is pseudocode!*/ template <typename STRUCT_TYPE, typenam...

c++ sending image to printer , (PRINT) .

Hello , this is code which i use to make image. Bitmap bitmap; bitmap.CreateBitmap(715, 844,1,1, NULL); CDC memDC; memDC.CreateCompatibleDC(NULL); memDC.SelectObject(&bitmap); CString SS="Sun Goes Down"; memDC.TextOutA(1,2,SS); CImage image; image.Attach(bitmap); image.Save(_T("C:\\test.bmp"), Gdiplus::Image...

Parameter marshaling protocol homework for RPC call?

I have a homework to build on paper a parameter marshaling protocol to be suited to call a method with one variable, or with an array (like a polymorphism). procedure(var1) procedure(array1) How would you define the protocol? How about the method in C++ ...

Min Binary Heap issue

Hi all, i need help with this minheap code: #include < vector> using namespace std; class heap { vector <int> v; public: int hSize() { return v.size(); } int rsize() { return hSize() - 1; } int parent(int i) { return ...

Terminating because of 6 signal

Hi, I compiled and ran my code and got the following error: Terminating because of 6 signal What is signal 6 and what causes it? ...

Web bot in C++/PHP.

Hello, I've recently started learning PHP, but I have a wide knowledge on C++. I've been wondering how to make a web bot and now, I would greatly like to make one. I won't be using this robot for spamming or anything, just as a test of what PHP/C++ can do online. I was wondering how I could go about doing this and if you have any article...

boost::bind & std::set::count compile error

Hi, Could anybody point me, please, what the difference is between making functor of set::insert and set::count in the below fragment? typedef std::set<std::string> s_type; typedef std::pair<s_type::iterator, bool>(s_type::*insert_fp)(const s_type::value_type&); typedef s_type::size_type(s_type::*count_fp)(const s_type::value_type&); ...

Window handling manager

I have a Windows box that is running three applications. When the applications are started each application creates a borderless window which is positioned such that they overlap in a particular way. At the moment, when I click on a control on the bottom window, it comes to the top of the window stack. I need to ensure that each windo...

What are the C# equivalent of these C++ structs

typedef union _Value { signed char c; unsigned char b; signed short s; unsigned short w; signed long l; unsigned long u; float f; double *d; char *p; } Value; typedef struct _Field { WORD nFieldId; BYTE bValueType; Value Value; } Field; typedef s...

Most portable and reliable way to get the address of variable in C++

Using & to get an address of a variable can be problematic if the variable type has overloaded operator&(). For example, _com_ptr_ has operator&() overloaded with a side effect of modifying the object. Now I have a complicated set of templates with functions like this: template<class T> void process( const T* object ) { //whatever ...

Search and replace with regular expressions under Visual Studio 2003

I have a large C++ code base that I'm doing some refactoring on where a number of functions have become redundant, and hence should be removed. So I would like to replace MyFunc(Param) with Param where Param could be a literal value, variable, function call etc... From the online help I gathered that the search parameters should ...

Please suggest some algorithm to find the node in a tree whose distance to its farthest node is minimum among all the nodes

Please suggest some algorithm to find the node in a tree whose distance to its farthest node is minimum among all the nodes. Its is not a graph and it is not weighted. ...

Is there pointer in C# like C++? Is it safe?

Hi, I write an application that work with tree data structure. I written it with C++, now i want to write it by C#. I use pointers for implementing tree data structure. Is there pointer in C# too? Is using of that safe? ...

How can I programmatically tell in C# if an unmanaged lib is x86 or x64?

How to Achieve this in C#. thanks... ...

boost lexical_cast throws exception

Hi I'm using boost libs for c++ and the function lexical_cast behaves really weird. If I do lexical_cast("0.07513994") it works fine, but if I use my variable which I need to convert, it throws the bad_lexical_cast exception. Here is the code: string word; istringstream iss(line); do { string word; iss >> word; double ...

What's the purpose of boost::detail::addr_impl_ref ?

Inside boost there's boost::detail::addr_impl_ref struct that basically has a constructor accepting a T& reference and an overloaded operator T&() that returns that reference. It is used in the implementation of boost::addressof(): template<class T> T* addressof( T& v ) { return boost::detail::addressof_impl<T>::f( boost::detail::ad...

std::map default value

Is there a way to specify the default value std::map 's operator[] returns when an key does not exist? Thanks! ...

C C++ - TCP Socket Class : Receive Problem

Hey, I did my own Socket class, to be able to send and receive HTTP requests. But I still got some problems. The following code (my receive function) is still buggy, and crashing sometimes. I tried debugging it, but it must be somewhere in the pointer arithmetics / memory management. int Socket::Recv(char *&vpszRecvd) { //vpszRecvd =...