How to pass 2D map as a parameter to a function in c++?
Hi all, I have a map like std::map< int, int> random[50]; How can i pass this map as a parameter to a function say Perform()? Thanks in advance. ...
Hi all, I have a map like std::map< int, int> random[50]; How can i pass this map as a parameter to a function say Perform()? Thanks in advance. ...
Hi everyone, I have a small problem with my compiler (VC++ 6.0). In my opinion, such a code should cause error; class Base { private: typedef int T; }; class Derived : private Base // Here the Base class can be inherited publicly as well. It does not play any role { public: T z; }; int main() { Derived o...
I wrote a application in MFC with C++. I need to write a class which can save all the data loaded from the database, These data might contain every kind of data type, such as int, string, byte, boolean, datetime and so on. We might filter, exchange columns, or sort on these data. For example: int int string bool double float .... st...
When developing an application which mostly interacts with a database, what is a good way to start? The application requires a lot of filtering based on user input, sorting and structuring. ...
I just recently installed VS2010 Beta 1 from the Microsoft website , I started a basic C++ Win32 Console Application , that generated the following code: #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { return 0; } I tried compiling the code just to see how it runs and just then I encountered several(over a 100) compiling...
I need a fully-recursive multiple-reader/single-writer lock (shared mutex) for my project - I don't agree with the notion that if you have complete const-correctness you shouldn't need them (there was some discussion about that on the boost mailing list), in my case the lock should protect a completely transparent cache which would be mu...
Does the Boost UBLAS library have a built-in solver for solving systems of equations? The documentation implies that all the ublas solver routines require the matrix to already be in triangular form. But, if a matrix is not in triangular form, is there anything in ublas that can reduce the matrix and then back-substitute, to solve a ...
Sometimes it make sense to hide string value from binary (executable) file. For example, it really make sense to hide encryption key from executable file. What I mean when I say "hide"? Such code: const char* encryptionKey = "My strong encryption key"; // Using the key after compilation produce executable file with such sec...
Hi, I am working on a Boost thread pool. I have a structure like this: class SimThreadPool { static SimThreadPool* getInstance(); boost::threadpool::prio_pool& getThreadPool() { return mThreadPool; } simTerrain::SimThreadPool::SimThreadPool() : mThreadPool(boost::threadpool::fifo_pool(1)) { } boost::thre...
I am trying to compare std::strings in a locale-dependent manner. For ordinary C-style strings, I've found strcoll, which does exactly what I want, after doing std::setlocale #include <iostream> #include <locale> #include <cstring> bool cmp(const char* a, const char* b) { return strcoll(a, b) < 0; } int main() { const char* s...
Is there a way to use the RSA keys I've generated with the Crypto++ API in OpenSSL? What I am looking for is a way to store the keys in a format that both Crypto++ and OpenSSL can easily open them. I'm writing a licensing scheme and would want to verify signatures and decrypt files using the Crypto++ API, but to generate the license fil...
Hi, In my C++ program, I'd like to run its executable sometimes with and sometimes without using OpenMP (i.e. multi-threading or single-threading). I am considering any of the following two cases how my code is using OpenMP: (1) Assume that my code is only having #include <omp.h> and OpenMP directives. (2) Same as (1) and my code furt...
Hi, first question here! I'm writing a grep type program for Windows, just for fun (using Mingw). It works well for text files where lines are terminated by '\n'. I'm using fstream::getline() for this. But I also need to be able to search files containing just a giant block of text with no line numbers. fstream::getline() fails here. I...
right now i am learning C++, and now I know the basic concept of template, which act just like a generic type, and i found almost every c++ program used template, So i really want to know when are we supposed to use template ? Can someone conclude your experience for me about c++ template ? When will you consider to use template ? Su...
Hi all, I am under a Unix environment, working in C++. I'm opening gvim from a directory in which a makefile called "Makefile" exists. When I try to use ":make" from within vim, I get: shell returned 2 (1 of 1): make: *** No targets specified and no makefile found. Stop. ...
Update: the shared_ptr in this example is like the one in Boost, but it doesn't support shared_polymorphic_downcast (or dynamic_pointer_cast or static_pointer_cast for that matter)! I'm trying to initialize a shared pointer to a derived class without losing the reference count: struct Base { }; struct Derived : public Base { }; shared_...
Hello all, I want to understand the external linkage and internal linkage and their difference. Also I want to know any const. variable in internally link by default unless otherwise stated as extern. What does this mean. ...
class Test { public: SOMETHING DoIt(int a) { float FLOAT = 1.2; int INT = 2; char CHAR = 'a'; switch(a) { case 1: return INT; case 2: return FLOAT; case 3: return CHAR; } } }; int main(int argc, char* argv[]) { Test obj; cout<<obj.DoIt(1); return 0; } Now, using the knowledge that a = 1 implies that...
I'm not sure I know how to ask this. say I have a function void myFunc ( int8 foo, float bar, int whatever ) { ... } is there a quick way of referencing a particular argument by its position? void myFunc ( float foo, float bar, float whatever ) { float f; f = ARG[1]; // f now equals bar } something to that effect? Follow ...
I run the Visual Studio 2008 profiler on a "RelDebug" build of my app. Optimizations are on, but inlining is only moderate, stack frames are present, and symbols are emitted. In other words, RelDebug is a somewhat optimized build that can be debugged (although the usual Release caveats about inspecting variables applies). I run both the...