c++

Should the caller initialize "out" parameters?

Many Win32 API functions have parameters specified to be "out". For example, GetIconInfo() description says about the second parameter that The function fills in the structure's members. This implies that the function doesn't ever read the original values stored in the "out" parameter - only changes them - and therefore the caller is fr...

Matrix multiplication using matrix template library (MTL 2)

Kindly give me some hint of matrix multiplication using MTL 2. Or any ref. or link for the documentation of MTL 2. ...

Delete operator and arrays

I have an abstract Base class and Derived class. int main () { Base *arrayPtr[3]; for (int i = 0; i < 3; i++) { arrayPtr[i] = new Derived(); } //some fuctions here delete[] arrayPtr; return 0; } I'm not sure how to use the delete operator. If I delete array of base class pointers as shown above, will this call de...

process termination C++

I have the following problem: I have an application (server that never ends) written in C++ running as a service containing inside the main thread also 3 threads (mainly doing IO). In the main loop I CATCH all possible exceptions. The process terminated and nothing was printed either by the main loop or by the threads themselves. I saw...

Any reason to use SecureZeroMemory() instead of memset() or ZeroMemory() when security is not an issue?

This MSND article says SecureZeroMemory() is good for cases when sensitive data stored in memory for a while should be for sure overwritten as soon as possible when no longer needed. Answers to this SO question explain why this can make a difference. Now is there any sence in using SecureZeroMemory() for initializing just every memory b...

Can you help me get my head around openssl public key encryption with rsa.h in c++?

Hi there, I am trying to get my head around public key encryption using the openssl implementation of rsa in C++. Can you help? So far these are my thoughts (please do correct if necessary) Alice is connected to Bob over a network Alice and Bob want secure communications Alice generates a public / private key pair and sends public key...

VS DataBreakpoints: difference between C and C++

hello, when you set a databreakpoint in MSVS, then you put in the address and the number of bytes and finally it lets you choose betwenn "C" and "C++". this last part i dont know what it is about? what is the difference of picking C and C++ in this situation? thanks! ...

static member variable inside a local class in c++?

I know we cannot declare a static member variable inside a local class... but the reason for it is not clear. So please can anybody explain it? Also, why can't we access a non-static variable define inside the function, within which the local class has been defined,directly in the local class member functions? In the code given below:...

Substituting 0A For \n

I'm at the time beginning the development of a simple hex editor(that only reads at the time). I want to substitute OA for "\n", I'm trying with this code: #include <iostream> #include <fstream> #include <iomanip> using namespace std; int main() { ifstream infile; int crtchar = (int)infile.get(); infile.open("test.txt", ifstre...

C++ class template of specific baseclass

Let's say I have the classes: class Base{}; class A: public Base{ int i; }; class B:public Base{ bool b; }; And now I want to define a templated class: template < typename T1, typename T2 > class BasePair{ T1 first; T2 second; }; But I want to define it such that only decendants of class Base can be used as templa...

why std::cin in step 3 is omitted ?

I don't understand, why cin >> W; in step 3 is omitted, if i input not a number (i.e. 's'). #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { short W = -1; cout << "step 1) W = " << W << endl; cout << "give a number: "; cin >> W; if ( cin.fail() ) { cout << "ERROR, bad num...

Show other data in QTableView with QItemDelegate

I have a QTableView connected with an QSqlTableModel. In the first column, there are only dates at this format: 2010-01-02 I want this column to show the date at this format (but without changing the real data): 02.01.2010 I know that I have to create an QItemDelegate for this column, but I don't know how I can read the existing data and...

Bugs related to template-functions in GCC 3.4.6

I ran into a strange compile error at the office today and I'm suspecting it to be a bug in our version of GCC (3.4.6). I've been able to boil it down to a few lines of code (below). The compile error I get is: test.cpp:26: error: expected primary-expression before '>' token test.cpp:26: error: expected primary-expression before ')' tok...

c++ create continguous array of type which is not known at compiletime

Hi! let's say i have a few different structure definitions (in fact, i have arround 50 such definitions): struct Type1{ int i; float f; }; struct Type2{ bool b1; bool b2; double d; }; they are all POD, but can contain completely different data. now, at runtime, i want to decide what type of those i need and then ...

System::IO::Directory::GetFiles in c++

I am having trouble in storing the files in a string array from a directory in c++, using System::IO::Directory::GetFiles in c++ Also would like to know if we could copy an entire folder to a new destination/ in c++ like given in http://www.codeproject.com/KB/files/xdirectorycopy.aspx for c# ...

Can the struct padding be safely used by the user code?

Assuming I have a struct like the following: struct Struct { char Char; int Int; }; and sizeof( int ) is greater than one and the compiler adds padding for the Char member variable - is the compiler-generated code allowed to change the values of the padding bytes? I mean if I use pointer arithmetic and write some data into th...

OpenGL: Best rendering method for terrain which texture coordinates changes in real time?

I need to render in real time rendered animations for my terrain textures; what is the best rendering method for doing this? the animation is done by adjusting the texture coordinates. I have a pre-built array for all of the animation frames texture coordinates, is there some way to make animations faster to render if you let opengl kno...

OpenGL: Adjusting LOD angle?

There must be some setting to adjust the angle when my textures miplevel changes... isnt there? It looks really ugly when the miplevel changes really early when my camera is looking at the road with angle of 10 or etc, or angle of 0 but looking straight forward to the road. What is the magical line of code? AND NO. not the LOD BIAS th...

Send and Recive file in socket programming in Linux with C/C++ (GCC)

I have a Server Client structure , both server and client can send and receive file. how to send and receive file in socket programming. one solution that I think is partition the file and send one by one segment, is there any library for file send and receive in Linux and C/C++? ...

Basic C++ debugging question

Do I absolutely have to learn assembly language to be able to use the debugger optimally? I noticed that during debugging sessions, I see these cryptic codes and CPU registers... (eax... blah blah). I shall assume that that's assembly and I am supposed to somehow decipher the cause of the problem from it. Is there some shortcut to ...