c++

c++ type error message from compiler, what does it mean?

I'm using g++ on fedora linux 13. I'm just practicing some exercises from my c++ textbook and can't get this one program to compile. Here is the code: double *MovieData::calcMed() { double medianValue; double *medValPtr = &medianValue; *medValPtr = (sortArray[numStudents-1] / 2); return medValPtr; } Her...

In SDL, does SDL_Quit() free every surface?

Basically, on surfaces that are going to exist right until the program terminates, do I need to run SDL_FreeSurface() for each of them, or would SDL_Quit() take care of all this for me? I ask mainly because the pointers to a number of my surfaces are class members, and therefore I would need to keep track of each class instance (in a g...

mysql_stmt_reset function fail

Hi Guys,I use mysql's lib to make a small sql program,when i use mysql_stmt_prepare,then mysql_stmt_reset to excute the query,it always return 1,the error msg is CR_SERVER_LOST,is some one have the same question?Help me Plz:D ...

Threading Model for a Game Engine

I'm interested in getting threading into the small engine I'm working on in my spare time, but I'm curious over what the best approuch is. I'm curious about the recommended way to sync the physics thread with the rest of the engine, similar to ThisGuy. I'm working with the Bullet Physics SDK, which already use the data copy method he was...

Inheritance and storing static class information

I'm trying to set up some stuff with Lua, but the specifics of Lua aren't important for my question. What I would like to be able to do is call a function, say OpenLib<T>(L), and have it get the table name for a particular class (as well as it's table) and register it with Lua. It essentially boils down to this: template <class T> sta...

Please help me understand this syntax (implementing static assert in C++)

This syntax was used as a part of an answer to this question: template <bool> struct static_assert; template <> struct static_assert<true> {}; // only true is defined #define STATIC_ASSERT(x) static_assert<(x)>() I do not understand that syntax. How does it work? Suppose I do STATIC_ASSERT(true); it gets converted to static_a...

problem with va_arg()

I want to wirte a function with variable arguments in this way: static void configElement(U32 localFaultId, char* name, U32 report, U32 localId, U32 detectTime, U32 ceaseTime,...) { U32 i = 0; U32 tmp...

the diffrence between unsigned long to UINT64

hi everyone is any one knows whats the diffrence between unsigned long to UINT64 i think its the same , but im not sure. the defenition of UINT64 is : typedef unsigned __int64 UINT64 (By Using StdAfx.h) thanks. ...

Virtual function and Classes

I need some answers to basic questions. I'm lost again. :( q1 - Is this statement valid: Whenever we define the function to be pure virtual function, this means that function has no body. q2 - And what is the concept of Dynamic Binding? I mean if the Compiler optimizes the code using VTABLEs and VPTRs then how is it Run-Time Polym...

C++ Typedefs and operator overloading

If you define a type like typedef int MY_INT; and go on to overload, say, the adition operator of MY_INT like MY_INT operator+(MY_INT a, MY_INT b); will MY_INT a, b; a + b; be different from int A, B; A + B; ? Sorry for any syntax errors. I'm not near a compiler and I want to ask this before I forget about it. ...

Knuth Permutation Algorithm Weird behaviour

Hi All, I have attached a code which gives weird outputs basing on cout statements. This program essentially computes the Knuth's Permutations. Input is say: run1 The code runs for first pass fine: Call trace will be: r un1 ur n1 nur 1 1nur n1ur nu1r nur1 After this run of code, the call returns correctly to step where urn...

Finding threading bugs

Is there any point trying to find threading problems at compile time? I'm talking about data races, deadlocks, corrupted state etc... ...

Open-source static code analysis tools for C++

Possible Duplicate: What open source C++ static analysis tools are available? Which open-source static C++ (not just C) code analysis tools are most suitable for porting code to 64-bit platforms? ...

Multimap containing pairs?

Is it possible for a multimap to contain within it pairs? IE, rather then being defined as multimap<char,int> for instance, it would be defined as multimap<pair, pair>? How would this multimap then be sorted? Also, how would one access the individual contents of each pair? ...

C++ NTL algorithms

Hi there, I cant seem to find any info on, which algorithms in the NTL C++ libraries are used. I am especially interested in the algorithms used for: Modular square root (SqrRootMod) Kernel of matrix over GF(2) (kernel for mat_GF2 objects) Greatest common divisor (GCD - this is probably euclids algorithm) Modular inverse (InvMod) J...

Can C++ be used with a top-down programming strategy?

I've heard that some languages are better suited for a top-down approach to solving problems, while others are intended more for use with a bottom-up technique. Is C++ one of these languages? And if so, which style best suits C++ programming? ...

Festival C/C++ API compiling an example, linking libraries error

Hi, I am having problems with the festival C++ API (Windows XP). After I make both festival and speech_tools succesfully (Cygwin), I have a file, called festival_example.cc, which contains: #include <stdio.h> #include <festival.h> int main(int argc, char **argv) { EST_Wave wave; int heap_size = 210000; // default scheme heap...

c++ Compression library - Deflate or Gzip

Hello dear StackOverflow! I'm looking for a useful compression library for c++ (on windows) I need preferably Deflate or Gzip, and i need it to be compatible with .NET's System.IO.Compression. Also if it will give me a decorator over a stream that would be great so i could do: std::ostringstream stringStream; CompressionStream cs(st...

How to check whether a folder or a file is hidden=

I want to find out whether a file or a directory is hide. At first I made use of CFile::GetStatus(), however I found this api sometimes will return FALSE. I don't know why, So I wrote the following code, However I found it is not stable. What is wrong with my code? BOOL IsHide(const CString& strPath, BOOL& bIsHide) { if (strPat...

Segfaults in malloc() and malloc_consolidate()

My application segfaults sometimes and mainly in malloc() and malloc_consolidate() when I look at the backtrace in gdb. I verified that the machine has enough memory available, it didn't even start swapping. I checked ulimits for data segement and max memory size and both are set to 'unlimited'. I also ran the application under valgrind...