c++

How to pack the required bits of a structure in a char* ?

Language : C++ I am working on Bit Packing (Extracting the required bits from the given data and packing them in a char*) . My code currently supports : - Integers - Characters - Strings Now if I have to store the required bits of a structure, how should I go about it ? I mean what should I expect as input parameters for a generaliz...

is there any way to inline just some selective calls to a function not all of them?

Is there any way to inline just some selective calls to a particular function not all of them? cause only form I know is declaring function as such at beginning and that's supposed to effect all calls to that function. ...

Extending RUMBA/3270 client using COM interface or EHLLAPI

Hi All In my application i want to listen for any RUMBA/3270 (It is a 3270 emulator) screen update/event which i can capture and get the text/byte stream coming from mainframe. Once there i can use that stream for data mining. In the RUMBA data-sheet they have mentioned that RUMBA 3270 emulator could be extended either by using EHLLAPI...

Scope problems in template C++

Is there any scope problem in this program? #include<iostream> using namespace std; template<class Type> class Base { public: Type member; Base(Type param): member(param){ } }; template<class Type> class Derived: public Base<Type> { public: Derived(Type param):Base<Type>(param){ // ...

Can dereferencing of pointer throw?

I'm teaching myself techniques of programming with exception safety mode of ;) and I wonder if dereferencing a pointer could ever throw an exception? I think it would be helpful for all C++ programmers to know all operations that are guarantied to not throw so I would be very grateful if someone could compose such list. ...

Problem with loading JPEG file from resources in MFC C++ application

The following code works correctly under Windows XP: CImage image; RECT destRect; int nResource = 10; CResourceStream stream(0, MAKEINTRESOURCE(nResource), _T("JPEG")); HRESULT hr = image.Load(&stream); image.Draw(hDC, destRect); But on Windows 7 image.Load returns E_FAIL though creating CResourceStream reads JPEG file from resou...

Is there no way to upcast into an abstract class and not modify it each time a class is derived from it?

#include<iostream> using namespace std; class Abs { public: virtual void hi()=0; }; class B:public Abs { public: void hi() {cout<<"B Hi"<<endl;} void bye() {cout<<"B Bye"<<endl;} }; class C:public Abs { public: void hi() {cout<<"C Hi"<<endl;} void sayonara() {cout<<"C Sayo...

How can I change wxMenu's Text color?

I want to change wxMenu's Text color,but not MenuItem's text color.Thank you for your advices. ...

Boost Shared_Ptr assignment

Why can I not do this? boost::shared_ptr<QueuList> next; void QueuList::SetNextPtr(QueuList* Next) { boost::mutex mtx; boost::mutex::scoped_lock lock(mtx); {// scope of lock //if (next == NULL) // is this needed on a shared_ptr?? next = Next; // Why can I not assign a raw ptr to a shared_ptr???? } }...

Installing latest 1.44 boost library under ubuntu 10.04

I have ubuntu 10.04 and want to install the latest boost library 1.44_0 I downloaded the tar.gz file and unpacked it into /usr/local/boost_1_44_0 I already have the boost 1.40 version install from synaptic. So I want to compile and link against 1.44 because I'm wanting to use some new libraries that are not in the older version such a...

How to use shared_ptr in a member which is not a shared_ptr?

Hi! I'm working on a couple of classes and I'm wondering how I can use a normal member in my application class, where the member needs to use shared_from_this()? Here is some code to clarify what I mean (see comments) class Observable { public: void addObserver(boost::shared_ptr<Observer> observer) { // add to a list }...

Lack of ortogonality in templates between class and function

// InternalTemplate.cpp : Defines the entry point for the console application. // #include "stdafx.h" template<class T> struct LeftSide { static void insert(T*& newLink, T*& parent) { parent->getLeft() = newLink; newLink->parent = newLink; } }; template<class T> struct Link { T* parent_; T* left_; T* right_; T*& getParent()...

Using operator[] on empty std::vector

I was advised a while ago that is was common place to use std::vector as exception safe dynamic array in c++ rather than allocating raw arrays... for example { std::vector<char> scoped_array (size); char* pointer = &scoped_array[0]; //do work } // exception safe deallocation I have used this convention multiple times wit...

How to copy a certain number of chars from a file to a vector the STL-way?

If I want to copy the contents of a file to a vector, I can do it like that: std::ifstream file("path_to_file"); std::vector<char> buffer(std::istream_iterator<char>(file), std::istream_iterator<char>()); My question is, how would I do this if I want to copy only the first n chars? Edit I could write my own ...

How to use STL unsorted key-value as pair in map

Hello, I need to use STL C++ map to store key value pairs. I need to store more than one data information in stl map. e.g Need to store DataType,Data and its behavior as(in param/outparam) all in string format. But map always use key value pair so if I store it like std::map<map<"int","50",>"behavior">. But always it sorts the...

Same code using floats on two computers gives two different results

I've got some image processing code in C++ which calculates gradients and finds straight lines in them with the hough transformation algorithm. The program does most of the calculations with floats. When I run this code on the same image on two different computers, one Pentium IV running latest Fedora, the other a Core i5 latest Ubuntu...

buffering in iostream

hello everyon, can somebody please explain, what exactly does it mean? I'm trying to understand what is the difference between clog and cerr, difference is only in buffering thanks in advance ...

Intrusive list threadsafe - best way

How do you create an intrusive slist (boost) that is threadsafe so that multiple threads can remove items or add items? I'd want fairly fine grained locking; so I can lock only the necessary nodes and not the whole list each time. Do I just write a wrapper class around boost slist or is it better to just implement it myself? ...

difference between logical and physical const-ness

hello, what is the difference between these two terms, and why do I need mutable, thanks in advance for any help ...

How to deduce class type from method type in C++ templates?

In templates as shown below, I would like the call Run(&Base::foo) succeed without the need to name the Base type twice (as is done in the compiling Run<Base>(&Base::foo) call). Can I have that? Possibly without adding a ton of Boost headers? With the provided code, I get an error of: prog.cpp:26: error: no matching function for call t...