c++

Returning stack data in C; Does it unallocate correctly?

I was reviewing a friend's code and got into an interesting debate on how C/C++ allocates memory on the stack and manages its release. If I were to create an array of 10 objects in a function, but return said array, does it release when the function pops (hence making the given data invalid) or is it placed into the heap (which raises th...

Counting down in for-loops

I believe (from some research reading) that counting down in for-loops is actually more efficient and faster in runtime. My full software code is C++ I currently have this: for (i=0; i<domain; ++i) { my 'i' is unsigned resgister int, also 'domain' is unsigned int in the for-loop i is used for going through an array, e.g. array[i] =...

Why does std::ends cause string comparsison to fail?

I spent about 4 hours yesterday trying to fix this issue in my code. I simplified the problem to the example bellow. The idea is to store a string in a stringstream ending with std::ends, then retrieve it later and compare it to the original string. #include <sstream> #include <iostream> #include <string> int main( int argc, char** ...

Forward declaration of a typedef in C++

Why won't the compiler let me forward declare a typedef? Assuming it's impossible, what's the best practice for keeping my inclusion tree small? ...

Inter-Thread Communication (and libraries?)

Hi, If have I have a game engine that has multiple threads that all work with one scene graph, what are techniques to ensure everything is synchronized whenever that scene graph changes? What kind of libraries are out there to help with that? Thanks! ...

Learning Graphical Layout Algorithms

During my day-to-day work, I tend to come across data that I want to visualize in a custom manner. For example, automatically creating a call graph similar to a UML sequence diagram, display digraphs, or visualizing data from a database (scatter plots, 3D contours, etc). For graphs, I tend to use GraphViz. For UML-like plots and 3D pl...

What are the rules of the std::cin object in C++?

I am writing a small program for my personal use to practice learning C++ and for its functionality, an MLA citation generator (I'm writing a large paper with tens of citations). For lack of a better way to do it (I don't understand classes or using other .cpp files inside your main, so don't bother telling me, I'll work on that when I...

Restrict inheritance to desired number of classes at compile-time

We have a restriction that a class cannot act as a base-class for more than 7 classes. Is there a way to enforce the above rule at compile-time? I am aware of Andrew Koenig's Usable_Lock technique to prevent a class from being inherited but it would fail only when we try to instantiate the class. Can this not be done when deriving itse...

good c++ documentation design example?

Hello. I'm tuning documentation generator for internal purpose that generates HTML documentation for C++ classes and methods. Is it any example available of good HTML documentation design? MSDN ( like this ) looks kinda outdated, same is doxygen / javadoc / sphinx results. Anyone ever see an documentation that looks REALLY good? ...

Where to start with FastCGI and C++

Anyone have any links or resource regarding writing a proper C++ FastCGI application? (on top of Apache using mod_fastcgi or mod_fcgid). ...

Windows Function

In my project i have 2 radio button "File" and "not File" and i also hav a textbox called "width".. I need to disable the text box when i click on "not file" radio button and once i click "file" radio button it should enable the textbox.. Can u tell me the function in Windows programming in visual c++ EDIT : "Add variable" is disabled...

C++ FastCGI parsing POST requests in to various form fields

I am writing a C++ app on FastCGI using libfcgi++. When I do a POST or GET request, is there a library out there that would parse the different fields? For example for a GET /fastcgi.fcgi?var1=data1&var2=data2 would return something that's easier to access var1 and var2? Same for a multipart POST request. ...

Convenient way to call GC::KeepAlive in C++/CLI scenarios?

Hi I'm writing some managed wrappers using C++/CLI. The problem is that the GC sometimes disposes the object while I'm using unmanaged members from it. (I think this behaviour is insane but this is another topic). For more details see: http://stackoverflow.com/questions/134653/finalizer-launched-while-its-object-was-still-being-used ht...

FastCGI C++ vs. A Script Language (PHP/Python/Perl)

What are the ups and downs of using FastCGI C++ vs. PHP/Python/Perl to do the same job. Any performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks). ...

Is there a TeX API for C++?

Hi Guys, I want to preview TeX formulas in my User Interface. After a long time searching, it seems to me that there is no other possibility than write the formula into a .tex file call tex with system() and write a dvi file call e.g. dvipng with system() and write a png file load this file into the GUI clean up(erase all these files)...

How to calculate sha1sum of a file in c++?

I tried system calls, but since it`s not the best solution I thought there should be some other way of calculating checksums. Is there any library or function that enables calculating file's checksums in c++ with various algorithms? ...

Optimization settings in VS

I am working on an application/GUI created with Win32/ATL . So there is UI field( text field) which works fine as designed in debug build. With release build it gets malformed and it looks like the width of text field is infinite. It works fine in debug build but creating issues in release build. So my question how same code can work in ...

Prevent linker from removing globals

I am using static global variables constructors as a trick to conveniently register functions, the idea goes something like this: typedef int (*FuncPtr)(int); struct RegHelper { RegHelper(const char * Name, FuncPtr Func) { Register(Name, Func); } } #define REGISTER(func) RegHelper gRegHelper_ ## func (#func, func); ...

What is a good tutorial for C++ policy-based class design?

I have just started reading Modern C++ Design Generic programming and Design Patterns Applied and I am wondering if I need to go through some very basic tutorial on policy-based class design before I dive in. Will chapter 1 provide all I need to follow it? I am already experienced with template usage (STL/boost/Poco) and writing templat...

C++ Macros: manipulating a parameter (specific example)

I need to replace GET("any_name") with String str_any_name = getFunction("any_name"); The hard part is how to trim off the quote marks. Possible? Any ideas? ...