c++

What are the schools of OOP ?

Are there philosophical differences between Smalltalk OOP and Simula OOP ? This is a question related to Java & C# vs C++ indirectly. As I understand, C++ is based on Simula but Java and C# are more or less from the Smalltalk family. ...

How to diagnose Java JNI EXCEPTION_ACCESS_VIOLATION errors in Windows Vista

We have a Java application that uses some C++ libraries through JNI. The application used to work just fine in Windows XP, but it does not work in Windows Vista, it just crashes the JVM right away. We also wrote the C++ libraries and produced JNI bindings using SWIG. We are a little bit clueless on where to start looking for a way to f...

Declare and initialise an array of struct/class at the same time

1. I know that it is possible to initialise an array of structures in the declaration. For example: struct BusStruct { string registration_number; string route; }; struct BusStruct BusDepot[] = { { "ED3280", "70" }, { "ED3536", "73" }, { "FP6583", "74A" }, }; If the structure is changed into a class, lik...

Buffer Overflow (vs) Buffer OverRun (vs) Stack Overflow

Possible Duplicate: What is the difference between a stack overflow and buffer overflow ? What is the difference between Buffer Overflow and Buffer Overrun? What is the difference between Buffer Overrun and Stack Overflow? Please include code examples. I have looked at the terms in Wikipedia, but I am unable to match with pr...

unresolved external symbol ...QueryInterface

...

Error When Reading a Sequencial File In C++

Hello, I'm having some problems when i try to compile my sample C++ project, i'm trying to read a sequencial file, but when i compile i got some errors, here is the code: // ReadClientFile.cpp // Lendo e imprimindo um arquivo sequêncial. #include <iostream> using std::cerr; using std::cout; using std::endl; using std::fixed; using std...

C++: member pointer initialised?

Code sample should explain things: class A { B* pB; C* pC; D d; public : A(int i, int j) : d(j) { pC = new C(i, "abc"); } // note pB is not initialised, e.g. pB(NULL) ... }; Obviously pB should be initialised to NULL explicitly to be safe (and clear), but, as it stands, what is the value of p...

sprintf and char [] vs. string

I need to pass const char * to a function. Before I pass it, I usually need to build it from some variables. I can never decide which approach is more elegant, and overall better: Allocate an array long enough to fit the text and use sprintf to build the final variable and pass it to the function. Initialize string s with a variable us...

first function input being skipped after loop

The title is self explanatory. For some reason in the loop in int main(), if the user wants to input another book, the loop skips the input of the first function and goes straight to asking for the author's name. For example: Title: The Lord of the Rings Author: J.R.R. Tolkien Copyright: 1954 Enter ISBN numbered separated by spaces: ...

Description of datamodule in dll?

I created a costumer's database program. I have a problem in which I create a data module in a DLL and I compile it but then get some error below. My concept is The data module created in DLL and I insert ADO components in the data module. This data module is used in another form. I created a db grid in the form but it doesn't ...

Displaying a video in DirectX

What is the best/easiest way to display a video (with sound!) in an application using XAudio2 and Direct3D9/10? At the very least it needs to be able to stream potentially larger videos, and take care of the fact that the windows aspect ratio may differ from the videos (eg by adding letter boxes), although ideally Id like the ability to...

__OBJC__ equivalent for Objective-C++

I'm compiling a .mm file (Objective-C++) for an iPhone application, and the precompiled header fails to include the base classes. I tracked it down to the following: #ifdef __OBJC__ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #endif Turns out, __OBJC__ is undefined for mm files, whereas it is defined for standar...

difference between global operator and member operator

Is there a difference between defining a global operator that takes two references for a class and defining a member operator that takes only the right operand? Global: class X { public: int value; }; bool operator==(X& left, X& right) { return left.value == right.value; }; Member: class X { int value; bool operato...

C/C++ Thread-safety of tmpnam?

I need to use the tmpnam function in C++, but I need to know about its thread safety. Namely, If I have several threads which will each need to acquire a different name for a temporary file, am I guaranteed that each thread will receive a file with a different name? ...

How to download web resource using Digest authentication

What set of Windows API calls will allow downloading a web resource (specifically an XML document) when the site is protected using Digest authentication without having to enter a username and password? I can use MSXML's “open” function on the IXMLHTTPRequest interface, but it requires a username and password to be supplied even thoug...

Good design mechanism for exposing class internals to future predicate functors?

I have a class Widget with some private internals, but I would like to expose these internals to predicate functors (only) via friendship. class Widget { ComponentA a; ComponentB b; friend class WidgetPredicate; }; class WidgetPredicate : public std::unary_function<bool, const Widget&> { bool operator () (const Widget& w...

some OVERLAPS using WSASend not returning in a timely manner using GetQueuedCompletionStatus?

Background: I'm using CreateIoCompletionPort, WSASend/Recv, and GetQueuedCompletionStatus to do overlapped socket io on my server. For flow control, when sending to the client, I only allow several WSASend() to be called when all pending OVERLAPs have popped off the IOCP. Problem: Recently, there are occassions when the OVERLAPs do ...

STL algorithim for merge with addition

Hi; I was using stl::merge to put two sorted collections into one. But my object has a natural key; and a defined addition semantic, so what I am after is a merge_and_sum that would not just merge the two collections into a single N+M length collection, but if the operator== on the object returned true, would then operator+ them. I ha...

C++ Runtime string formatting

Usually I use streams for formatting stuff however in this case ?I don't know the format until runtime. I want to be able to take something like the following format string: Hello {0}! Your last login was on {1,date:dd/mm/yy}. ...and feed in the variables "Fire Lancer" and 1247859223, and end up with the following formatted string: Hell...

should C++ class "helper functions" be members, free, or anon-namespace free?

So, I have a class. It's a useful class. I like a lot. Let's call it MyUsefulClass. MyUsefulClass has a public method. Let's call it processUsefulData(std::vector<int>&). Now suppose processUsefulData really does two things and I want to refactor it from this: std::vector<int> MyUsefulClass::processUsefulData(std::vector<int>& data) { ...