c++

How to rescale an image with c/c++ in windows?

What's the shortest solution in c/c++? ...

pthread return value error

I am new to Linux programming. I am returning a value from thread. But when compiled it is listing some errors. I am listing the code and error below. Please help me to understand why the error and how to solve it. code #include <pthread.h> #include <stdio.h> void* compute_prime (void* arg) { int x = 2; return (void*) ...

Programming Language for Creating DLL: C++ or C#

Hi, This is NOT a Programming doubt! I am going to write a DLL for some application. I have two options to choose from: C++ or C# In which language I should write DLL? Does that affects functionality? I am a completely newbie and Unaware of both C++ and C# (but Some Small programs in C#). What are Pros and Cons about Writting DLL in ...

Do friends in c++ be mutual?

Possible Duplicate: Friend scope in C++ I am new to c++ and just wondering it! ...

multithreaded logging for high performance application

I have an application (server application) that needs an extensive amount of logging implemented and shouldn't be too affected performance wise by enabling logging. The application has a thread pool of worker threads performing the work. Originally I was going to just log on these thread pool threads, but then I'd need to lock practica...

can i build c++ none blocking tcp server and not in C like (node.js.nginx)

Hi why each none blocking server is build with C ? cant i build it with c++ ? ...

Const and non-const access resolves to different overloads?

Let me say we have a simple programming task. But for the sake of clarity I start with few code samples. First of all we written a some kind of data container class but for the purposes of task no matter what the class is. We just need it to behave const-correct. class DataComponent { public: const std::string& getCaption() const { ...

Efficiency. Function return values versus output parameters

Hi, Function return values versus "output" parameter, which one is faster? I think I best explain using what I am currently working on. // specify identifier and return pointer. SceneNode* createSceneNode(const String& desired_identifier); // f1 // auto-gen identifier and return as string. String createSceneNode(SceneNode*& out_ptr_...

How to sync windows explorer with windows command prompt?

Is there a way to control/navigate windows explorer from the windows command prompt? Or just sync explorer with the prompt's current directory? If for example I enter the command "c:>cd d:\folder\" in the prompt, the prompt's current directory will change right? What I'm aiming for is that as soon as prompt's directory changes the explo...

Profiling line-by-line in C++

Hey, I have a C++ program I am trying to optimize. Since I want it to run fast, I am not using a lot of function calls. Most profiling tool I have seen can give you profiling info in a function-call resolution. However, I would like it in a line-by-line resolution. Is there some option like this? I am using Visual Studio 2010 on Windo...

How do I get PCRE to work with C++?

This is a newbie question but I hope I can express my question as clearly as possible. I'm trying to do pattern matching in C++. I've downloaded the Win32 version of PCRE from here and I've placed the downloaded pcre3.dll and pcreposix3.dll files into the folder of Dev-CPP's lib folder (I'm using Bloodshed Dev-C++ 4.9.9 IDE). I've a...

reference to a std::vector of derived class pointers as input parameter to a function

Hi, First of all I'd like to apologize if there's another question like this one and I didn't find it. I've been trying but since the problem is quite specific I couldn't find one. Now, the problem. I have a Base class and a Derived class (say BNode and DNode ), and I have a std::vector of BNode*. I have also a function which receives...

Use wildcards with FindWindow api call with mfc.

I am using FindWindow in an mfc application. HWND hWnd = ::FindWindow(NULL, _T("foobar v5")); I would like to use FindWindow with wildcards so that I can match just foobar. Thanks ...

what is the workaround for floating point inacurracy?

Here's the code snippet: float pNum = 9.2; char* l_tmpCh = new char[255]; sprintf_s(l_tmpCh, 255, "%.9f", pNum); cout << l_tmpCh << endl; delete l_tmpCh; the output is: 9.199999809 What to do in order for the result to be 9.200000000 Note: I need every float number printed with 9 decimals precision, so I don't want to have 9.2 ...

Expected Initializer Before 'double'

What could be the possible error in this line : double bx; bx I define universally ! but I am getting the above error on compiling .Even for float bx; I get the same kind of error . The surrounding code is : #include "header.h" #include "ball_pad.h" #include "pingpong.h" #include "texture.h" #include "3dsloader.h" float A = 90.0f;...

Pointer to array deletion

Hi, I have an array that is passed via a function and assigned to a class member which is a pointer. class ClassA{ unsigned char * pointerToArray; ClassA(unsigned char array[]){ pointerToArray = array; } ~ClassA(){ //what to do here } }; Now i have this second class which uses this class ClassB { std::list<ClassA> cl...

c ++ digits after decimal point.

Hey I have a float number for example 12.12123 Is there a function which would display only number with 2 digits after decimal point 12.12 ? Here is the code: y1 = ( c1 - (a1 * x)) / b1; y2 = ( c2 - a2 * x) / b2; if (y1 == y2) cout << "The same"; so if the y1 = 1.001 and the y2 = 1.002 they do not appear as the same. I tried to...

Searching std::unordered_set by hash value and predicate

How can I search a std::unordered_set knowing hash value and having some predicate object? (The predicate determining equivalence by pred(x) && pred(y) meaning x == y.) ...

What is the best practice in C++ to declare objects within classes?

Hi All, I'm working on a class library in VC++ that shall have ref classes and some native code. Now, I need to use five native objects from an external framework. those objects must be declared on the heap NOT on the stack. I want encapsulate those objects in some sort of a structure knowing that constructors need to be called. Thank ...

Designing and coding a non-fragmentizing static memory pool

I have heard the term before and I would like to know how to design and code one. Should I use the STL allocator if available? How can it be done on devices with no OS? What are the tradeoffs between using it and using the regular compiler implemented malloc/new? ...