c++

malloc only allocates 4 bits?

I'm trying to make some c programs, ut i'm stuck at the malloc command. This is my code: #include <stdlib.h> #include <iostream> #include "Oef1.h" using namespace std; some methode clled by main{ int ** q=NULL; int m=read(q); } int read(int ** q){ int m=3; int n=...

C++: declaring a class with functions, that handle string

Hello, I haven`t found answer to my question using search, though I thought it is simple and popular. Anyway, my question is: I have got a header file, which declares a class and functions in it. It looks like that: #ifndef SOME_CLASS_H #define SOME_CLASS_H #include <string> class mySomeClass { public: bool a_func(string & my...

How can I get my very large program to link?

Our next product has grown too large to link on a machine running 32-bit Windows. The sum total of all the lib files exceeds 2Gb and can only be linked on a 64-bit Windows machine. Eventually we will exceed that boundary, since our software tends to grow rather than contract and we are using a 32-bit linker (MS Visual Studio 2005): we ...

Where to find open-source widgets for Qt library?

I have found quite good stuff here. If you know other sites that have some good code for Qt library (some additional codes, good examples, except the Qt standard examples, of course), please share with us. ...

Loop streaming .ogg audio - OpenAL

Dear all, I have problem looping a streamed ogg vorbis file. This is the code : fslStream_OGG::fslStream_OGG() { className = "fslSound"; iMemSize = 0; iLength = 0; bSourceRelative = false; bIsLooping = false; bForceStop = false; bActive = false; source = buffer = 0; current_gain = 1.0f; outer_gain = 0; snd_info.uiChannels =...

Query peak memory usage of a running process.

I need to query the peak memory usage by a running process from a C++ code. I looked at GetProcessmemoryInfo() function but it does not seem to give the information about peak memory usage by a process. Is there any function that does that and is it exported by kernel32.dll. ...

C++ template function with unknown number of arguments

Hi, this is probably a useless problem but it stuck on my mind for few hours. I wanna write a function which accepts some (POD) arguments, convert them to string and return the concatenation. for example template<typename A, typename B> string ToString(A a, B b) { stringstream ss; ss << a << b; return ss.str(); } pretty ...

default constructor value for bool type

Hi alltogether, I am just wondering, which value the default constructor of bool type returns in C++. For instance writing such a code int i = int(); guarantees that the variable i will be initiated always with 0. I guess such an initialization routine is possible as well bool b = bool(); But unfortunately I could not find anywh...

is there a good c/c++ to delphi converter(software)

i need a tool that can convert c/c++ code to delphi(object pascal) code, have tried openc2pas but it is pretty much useless and a pain to use is their a usable alternative?(free or commercial) ...

Can two windows apps communicate using the command-line?

I worked on a Unix app where two applicants ran and talked to each other using the command-line, i.e each had a loop something like (treat this as pseudo code): bool stop=false; do { stringstring cmdBuffer; cin >> cmdBuffer string ret = processCommand(cmdBuffer); if(ret.length()==0) stop=true; else cout << ret; } while...

templates and function objects - c++

i have a problem with this class. the goal is to make the main function work properly. we were supposed to implement the "And" function object so that the code will work. i can't find what is the problem with our solution. (the solution start and end are marked in comments in the code before the "main" function) can you please help? than...

fopen file from windows network location

I can open files from a mounted network drive, but not from an unmounted one e.g \\mycomp\folder2\hi.bmp Any work around for this? ...

(Ab)using constructors and destructors for side effects bad practice? Alternatives?

In OpenGL, one often writes code like this: glPushMatrix(); // modify the current matrix and use it glPopMatrix(); Essentially, the state is changed, then some actions are performed that use the new state, and finally the state is restored. Now there are two problems here: It's easy to forget to restore the state. If the code in be...

How to eliminate external lib/third party warnings in GCC

Hi everyone, In the software project I'm working on, we use certain 3rd party libraries which, sadly, produce annoying gcc warnings. We are striving to clean all code of warnings, and want to enable the treat-warnings-as-errors (-Werror) flag in GCC. Is there a way to make these 3rd party generated warnings, which we cannot fix, to disa...

Inheritance, Calling base class ctors

class Base{ public: Base(int val):_id(val){}; int _id; }; class Derived : Base { public: Derived(int val):Base(_id+val){}; }; int main(){ Derived d(60); } why doesn't this give an error? Base class is still not constructed but I'm able to use '_id'? thanks ...

preventing window maximisation/minimisation in x window system

i'm writing some low level window code for a window in x (in c++), and I want to prevent the user from either maximising or minimising the window. i don't mind whether this is done by rejecting the request to resize, or by removing the buttons themselves. however, i am tied to x and can't use qt or other higher-level libraries which i kn...

BOOST: recursive shared_mutex ?

Seems that Boost's shared_mutex is non recursive.. Is there anyway around this? (without re implementing the whole stuff) ...

Unhandled exception at 0x6c70f2ca in xxx.exe 0xC0000005: Access violation reading location 0xcdcdcdf1 how to debug this?

Hello i have c application that im compiling in visual studio 2010 im getting this error in one of my functions generically how can i debug this kind of exception ? the function is from dll , other functions working but not this one . ...

What does main return?

I have this question, which i thought about earlier, but figured it's not trivial to answer int x = x + 1; int main() { return x; } My question is whether the behavior of the program is defined or undefined if it's valid at all. If it's defined, is the value of x known in main? ...

Why do some experienced programmers write expressions this way?

Possible Duplicates: How to check for equals? (0 == i) or (i == 0) Why does one often see null != variable instead of variable != null in C#? I've been having a look at an odd tutorial here and there as well as some DirectX code and noticed that many experienced C++ programmers write expressions in the following way: (<cons...