c++

Will accessing a class object through a pointer to its derived class break strict aliasing rules?

void foobar(Base* base) { Derived* derived = dynamic_cast<Derived*>(base); // or static_cast derived->blabla = 0xC0FFEE; if (base->blabla == 0xC0FFEE) ... } On compilers with strict aliasing, is "derived" an alias for "base"? ...

When to use OOP instead of Arrays

When should I use OOP instead of an array? Does the size of my project matter? To provide a little background: I'm making a small program for my friend. Basically, he wants to add different scores to each other to be able to see his grade. (Yes, I know there's commercial software, but this is also a fun exercise.) Anyways, from time to ...

How do we iterate through all elements of a set while inserting new elements to it?

consider this: // set_iterator.cpp : Defines the entry point for the console application. #include "stdafx.h" #include <iostream> #include <set> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { set<int> a1; set<int> a2; a1.insert(3); a1.insert(4); a1.insert(5); a2.insert(1); a2.insert(2); a2.insert(6); set<int>:...

Stream Insertion Overloading C++

Im trying to call the function: friend ostream& operator<<(ostream& out, stack::myItem& theItem); that is public to my stack object: class stack { public: stack(int capacity); ~stack(void); void method1(); ... private: struct myItem { int item; }; ... public: friend os...

how to create minidump for my process when it crashes

Hi I am not able to create minidump form my process by changing system setting.So my Question is Will system create a minidump for user process when they crashes If yes , which setting i need to configure Or do i have to create minidump programmatically. How much effective minidumps are while investigating a crash ...

C++ run time error with protected members

I am trying to do a homework assignment where we insert a string into a string at a specified point using a linked stack, hence the struct and typedef. Anyway, when I try to access stringLength in the StringModifier class inside the InsertAfter method, I get a run time error and I cannot figure out what the problem is. I should be able t...

rename a file in c

I was just wondering how could i rename a file on unix platform using a c program without using the standard rename function.any ideas? rename a file in c ...

General printing raster and/or vector images

Hi, I'm looking for some API for printing. Basically what I want to achieve is to print set of pixels(monochromatic bitmap which I store in memory) onto the generic paper format (A4,A5..etc.). What I think that would be minimum API is: printer devices list printer buffer where I could send my in-memory pixmap (ex. like winXP printer...

Programming in gamedev (performance related)

I am just wondering how some things work in gamedev: I know, that the performance is actually crucial so there is still (and I think never will be) no place to use managed languages/platforms as Java/.NET just because of their performance. But... recently I have read somewhere here on SO, that even though people creating games use C++ ...

C++ Passing two dimensional arrays as parameters to classes

I've got a Car class and a Track class. The Car class constructor takes a road parameter which is supposed to be a 32x32 boolean array. Then I've got a Track class which creates a Car class and is supposed to pass the 32x32 array to it's constructor. Note that I've simplified the code somewhat by removing irrelevant bits and pieces. ...

How to assign a value to a TCHAR array

I have a TCHAR array in my C++ code which I want to assign static strings to it. I set an initial string to it via TCHAR myVariable[260] = TEXT("initial value"); Everything works fine on this. However, when I split it in two lines as in TCHAR myVariable[260]; myVariable = TEXT("initial value"); it bugs and gives a compiler error: ...

Pointer to class method

Hello! I'm trying to have pointer to class methods, so I have something like: class foo { public: static void bar() { } }; void (foo::*bar)() = &foo::bar; That doesn't compile :( I get: > error: cannot convert ‘void (*)()’ to > ‘void (foo::*)()’ in > initialization ...

Why is my nest class being seen as abstract?

I have an abstract base class which contains a private nested implementation. visual c++ is giving me the following error when I try to instantiate the non-abstract nested implementation: error C2259: 'node::empty_node' : cannot instantiate abstract class (line 32) as far as I can tell, I've overridden all the abstract members of the ...

Why am I getting unresolved externals?

I am writing an immutable binary search tree in c++. My terminating nodes are represented by a singleton empty node. My compiler (visual c++) seems to be having trouble resolving the protected static member that holds my singleton. I get the following error: error LNK2001: unresolved external symbol "protected: static class boost::sh...

Invalid Class String Error when creating C++ Project in Visual Studio 2008 with Vista x64

After going through this Problem (connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=329986) that was related with registry permissions, now again, Visual Studio comes with another error. I have the same error as this guy, I have searched all the internet and it seems nobody has resolved it yet. When I create a C+...

How to include a newline in a C++ macro or how to use C++ templates to do the same ?

I saw the following question: http://stackoverflow.com/questions/98944/how-to-generate-a-newline-in-a-cpp-macro Let me give a brief requirement of a need in newline in a C++ preprocessor. Am working on ARM Realview compiler 3.1 on a code which uses embedded assembly code with C++ code. #define DEFINE_FUNCTION(rtype, op, val) \ __as...

Signing data in C++ compatible with PHP's openssl library

I'm looking for a way to sign some data in C++ code which will then be sent to a PHP script for verification and processing. I want to use the OpenSSL module there, namely the *openssl_verify* function so I need something compatible with that. The application will be only for Windows so CryptoAPI might be fine but looking at the samples...

Installing multiple directx sdk versions

I have some DirectX applications I developed in college using DirectX August 2007 SDK. I would like to have August 2007 and the latest SDK installed so I can port my application to the newest framework. Does anyone have experience with having multiple frameworks installed, or is it discouraged? Thanks ...

Stop QNetworkRequest buffering entire request

How can I stop QNetworkRequest from buffering the entire contents of a QIODevice during a put/post to an HTTPS connection? It works fine when posting to HTTP but HTTPS causes the entire file to be read into memory before the post starts. ...

Can a program figure out its Oracle resource usage?

My boss would like to find a way for a running executable to ask Oracle, the size of the resources that the program is used. The purpose behind this is so that we can add to the user documentation/capacity planning documentation information on the size of the resources needed for each program. My Google-Fu is weak today, and I really...