c++

Best way to program piecewise-linear function on DSP TMS320C5509

There is a Table of pairs , which defines pieces bounds. And we are using straightforward algorithm: y = f(x) Calculate index n in Table using x Get Yn and Yn+1, compute linear interpolation Y Y is the answer. So i think, there must be more efficient method, could you please point me? ...

Best & Fast way to find out if an ip address is reachable

I need the fastest way to see if an ip address is reachable. On each ip address theres a server listening on a specific port so let me know if your method is about to find if a server is listening on a port. The reason for this is that suppose I have 10 ip addresses with 10 server listening on port 101 on each ip address. I want my clie...

Using Custom Events in QT4

I have an app that has a progress bar & spawns a worker thread to do some work & report back progress. The dialog class overrides the customEvent method so that I can process events that are being passed to the gui thread via the worker thread. Before I was using a QThread derived class as the worker thread and I changed it to use ACE_...

How can I call a method given only its name?

I'm trying to have method void run( string method ) which would run method in that class. For example: class Foo { public: void run( string method ) { // this method calls method *method* from this class } void bar() { printf( "Function bar\n" ); } void foo2() { printf( "Function foo2\n" )...

How do I dynamically create controls with the same visual style as their parent?

I'm using Visual Studio 2005 (and win32 API in C++), and I have a window which was designed using the built-in dialog box editor. At runtime, I want to be able to use CreateWindow() to add new controls to it. This works, however the controls I create all look really ugly. For the purpose of concreteness, the control I'm adding is a TabC...

Is there an STL algorithm to find the last instance of a value in a sequence?

Using STL, I want to find the last instance of a certain value in a sequence. This example will find the first instance of 0 in a vector of ints. #include <algorithm> #include <iterator> #include <vector> typedef std::vector<int> intvec; intvec values; // ... ints are added to values intvec::const_iterator split = std::find(values.beg...

Is ASSERT redundant?

ASSERT(pointer); pointer->x; In this code, the ASSERT seems to be redundant. If the pointer is NULL, pointer->x will fail anyway. Is my argument correct? ...

How do I display a CFormView in a mainframe?

I created an SDI MFC app without the doc/view support. The MFC template gives me an app with a blank window (And a menu, etc) I want to show my CFormView object on that main window. (Based on a dlg made in the gui editor) How do I do that? CreateWindow and showwindow don't seem to be all that is needed. All the web pages I find see...

Does Visual Studio support data cache operations?

Reading through some great presentations on low latency computing. They had a reference to IBM's XL C/C++ compiler data cache operation __dcbt (Data Cache Block Touch) for their cell compiler. The operation loads a block of memory into L1 cache. Does Visual Studio (or G++ or Intel) have similar functionality for Intel Processors? If so...

How does std::string overload the assignment operator?

class mystring { private: string s; public: mystring(string ss) { cout << "mystring : mystring() : " + s <<endl; s = ss; } /*! mystring& operator=(const string ss) { cout << "mystring : mystring& operator=(string) : " + s <<endl; s = ss; //! return this; return (mystring&)this; // why COMPILE ERROR } */ mystring o...

Memory leak in trivial stack implementation.

I'm decently experienced with Python and Java, but I recently decided to learn C++. I decided to make a quick integer stack implementation, but it has a massive memory leak that I can't understand. When I pop the node, it doesn't seem to be releasing the memory even though I explicitly delete the old node upon poping it. When I run it, i...

QMenu* << QAction* -- Help Me Write A Global QMenu Insertion Operator

If for no other reason than for my own amusement, I wish to write a global insertion operator so I can use the fancy code: aQMenu << aQAction1 << aQAction2 << aQAction2 << seperator << aQAction3; Perhaps you hate the syntax, but I would at least like to try my hand at using it. The problem is, that this is the first time I have tried...

Software protection alternative for Themida

Hi, We currently use Themida for our C/C++ software protection, but the highly number of false positives on anti-virus softwares are disturbing our client base. Does anyone knows any other software protector as good as Themida, but without the "make anti-virus crazy" flag? Thanks. ...

How to convert double* to a double?

Any ideas for this typecasting problem? Here's what I am trying to do. This is not the actual code: LinkedList* angles; double dblangle; dblangle = (some function for angle calculation returning double value); (double*)LinkedListCurrent(angles) = &double; I hope you get the idea. The last line is causing the problem. Initially angl...

STL with a custom data type

What am I doing wrong? #include <iostream> #include <deque> using namespace std; struct mystruct { int number1; int number2; }; int main() { std::deque<mystruct> mydeque; mydeque.number1.push_front(77); return 0; } ...

What is the best way to store double dimension vector in c++?

What is the best way to store double dimension vector in c++? std::vector <std::vector <int> > m_vector(N, std::vector<int>(M)); ... int k = m_vector[i][j]; How else? ...

How to get the fractional part of the seconds in UTCTime using time.h

I want to get the system time including fractional part of the seconds. Is it possible in standard c (ANSI C)? If not then tell me some libraries for window OS so that I make it possible. In Linux I have the following code with work fine for me. #include <sys/time.h> #inc...

Build automation by using platform specific project files or by using project generators?

There are some build systems that are able to generate platform specific project files like Visual Studio sln,vcproj,vcxproj files or XCode xcodeproj projects under OS X. One of them is CMake but I found out that the support for this is quite limited, buggy and that is very hard to keep it updated with newer versions (like VS 2010). A...

GDI fails conversion to indexed color with exact palette?

Summary Using Windows GDI to convert 24-bit color to indexed color, it seems GDI chooses colors which are "close enough" even though there are exact matches in the supplied palette. Can anyone confirm this as a GDI issue or am I making a mistake somewhere? Maybe there's a "please check the whole palette for color matches" flag which I...

newbie: Determinate CRT lib used by library

I'm developing application using VC++ 6. I have a 3rd party DLL. This library compiled as Multithreaded DLL (/MD) and my application too. But I fail to link: LINK : warning LNK4075: ignoring /EDITANDCONTINUE due to /INCREMENTAL:NO specification msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,stru...