c++

why imaxdiv_t __cdecl in such function does not want to compile under /clr:pure ?

so I have such code in my VS ffmpeg video encoder project in C++ which compies perfectly under CLR (inttypes.h part of ffmpeg's includes) // ISO C9x compliant inttypes.h for Miscrosoft Visual Studio // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 // // Copyright (c) 2006 Alexander Chemeris // // Redistribution...

Code optimization problem with variable argument list C++

Hi, I'm using Visual Studio C++ 2010 Express. I made this function with variable argument list: BOOL Send(SOCKADDR_IN toAddr, LPTSTR command, LPTSTR first, ...) { if (g_udpSocket == INVALID_SOCKET || command == NULL) return FALSE; va_list args; va_start(args, command); LPTSTR str = va_arg(args, LPTSTR); TCHAR szData[DEFAULT_ST...

public, protected, private

Hey, Take a look at this code: #include <iostream> using namespace std; class A { private: int privatefield; protected: int protectedfield; public: int publicfield; }; class B: private A { private: A a; public: void test() { cout << this->publicfield << this->protectedfield << endl; } void tes...

Compiling make based project with MSVC?

In OSX, I'm used to simply doing ./configure make But in MSVC when I do Project from existing code and try to compile I get hundreds of errors. I'm trying to compile GLU from the Mesa3D library. How could I do this in MSVC? Thanks ...

Convert LPSTR to BSTR using win32

I see how to do this using MFC, but what is the best way to convert a LPSTR to a BSTR in C++ using only the win32 libraries. ...

How does the address of stringstream buffer changes

When i use << operator to put values in buffer sometimes the address of buffer changes. does it copy the values to new address or move them to a new address in memory and how can i know the address where data is stored in? Also, I'd be interested in a book that covers about streams in c++. ...

Is there any tutorial on creating and compiling C++ .net libraries?

I want to create a C++ library. I want its API functions to be accessible from .net (C#). I will have a lot of unmanaged code that is compilable under clr. Where can I get a tutorial on creating such library\sln? ...

Struct vs namespace for C++ component based design

We have a component based C++ design, where each component is comprised of a public outer class that is used to group component interfaces. Each interface is defined as a nested class as shown below. struct ComponentContainer { class InterfaceClass_1 : public ComponentInterface { public: virtual ~InterfaceClass_1 (...

Double precision in C++ (or pow(2, 1000))

I'm working on Project Euler to brush up on my C++ coding skills in preparation for the programming challenge(s) we'll be having this next semester (since they don't let us use Python, boo!). I'm on #16, and I'm trying to find a way to keep real precision for 2¹°°° For instance: int main(){ double num = pow(2, 1000); printf("...

Proper inheritance

What is meant by proper inheritance? ...

C++ Overloaded Function Error

Hey everyone, I'm working with JNI on a current project, and am getting a strange error from my C++ code during compilation. I get an error stating: error: overloaded function with no contextual type information This is coming from the "nativegetsupportedciphersuites" line in the following array, which is mapping java functions with ...

Will new operator return NULL?

Possible Duplicate: Will new return NULL in any case? Say i have a class Car and i create an object Car *newcar = new Car(); if(newcar==NULL) //is it valid to check for NULL if new runs out of memory { } ...

Put function definition directly in the header file so the compiler can inline?

I tend to put the body of smaller functions right into the header file foo.h, not into the separate implementation file foo.cc, because then the compiler can always see those functions completely and decide to inline them. Example: // File "foo.h": struct Foo { // ... int GetCount() const { return count_; } }; Now any code t...

Array of objects created dynamically.

Possible Duplicate: How does delete[] know the size of the operand array? Assume i have an array of objects created dynamically Car *newcars = new Car[10]; delete [] newcars; How does the compiler know that there are 10 objects that need to be deleted. ...

Namespaces and C++

I have observed that in C++ namespaces are very rarely used while in .Net it is very common. Is there any particular reason for this. Also i would like to know if others have seen namespaces being used commonly in C++. EDIT: Actually i am referring to custom applications and not standard libraries like STL or any other thing. ...

Accelerated C++ - Ch 13 & 14 - Is a handle the same thing as a smart pointer?

I'm just about done Koenig & Moo's Accelerated C++ and in Chapters 13 & 14 they lay out the idea and implementation of a few Handle classes (simple, shared, reference counted). The classes encpasulate a raw pointer and abstract the allocation / deallocation of dynamic objects away from the client code to avoid all the dangers of raw poi...

Hitting Escape versus Enter triggering LVN_ENDLABELEDIT in CListCtrl

how can I differentiate between the two, when the edit field is empty in both cases? when the user hits escape, I assume user doesn't want the new value at all, when enter is hit, I assume the user wants an empty string for the edited item... ...

Difference between std::list<std::pair> and std::map in C++ stl

Hi, Can you please tell me the difference between std::list<std::pair> and std::map. Can I used find method on list too? Thank you. -- Clarification Question edited to be more clear. ...

C++ XQuery engine - zorba or XQilla or another

I have been using zorba for a little while and it seems to generally work. But it seems to leak memory here and there and I am having to look at other options. Has anyone had luck with any other XQuery engines in linux environment? ...

Asynchronous function call for C++

Hi, I need a hint how to implement asynchronous function calls in C/C++ ( or names of frameworks/API calls for windows and/or linux ) The use case is following: A parent thread calls a function. The function creates a child thread and returning, so call is non-blocking and parent thread can continue to do some job. For example pthrea...