c++

Problem using pantheios file stock back end

I am trying to use pantheios file stock back end to log from my dll in c++. The file gets created but nothing gets written to the file. Here is a snippet of my code if (pantheios::pantheios_init() < 0) { MessageBox(NULL, "Init Failed", "fvm", MB_OK); }else { MessageBox(NULL, "Init Passed", "fvm", MB_OK); pantheios::log_IN...

C++ a class with an array of structs, without knowing how large an array I need

New to C++, and for that matter OO programming. I have a class with fields like firstname, age, school etc. I need to be able to store other information like for instance, where they have travelled, and what year it was in. I cannot declare another class specifically to hold travelDestination and what year, so I think a struct might be ...

C++ Input Stream

I have a program that work with data which is paste to console. For example when the program is run and I paste delete 54545 add 4324 the program call delete function with parameter 54545, but wait for enter after 4324 to call second function. And I have no idea how to call it without press enter. example first line is how many fun...

C++ typename of member variable

hello everybody Is it possible to get typename of a member variable? For example: struct C { int value ; }; typedef typeof(C::value) type; // something like that? Thanks ...

Does throw inside a catch ellipsis (...) rethrow the original error?

If in my code I do the following snippet: try { doSomething(); } catch (...) { doSomethingElse(); throw; } Will the throw rethrow the specific exception caught by the default ellipsis handler? ...

System of linear equations in C++?

I need to solve a system of linear equations in my program. Is there a simple linear algebra library for C++, preferably comprised of no more than a few headers? I've been looking for nearly an hour, and all the ones I found require messing around with Linux, compiling DLLs in MinGW, etc. etc. etc. (I'm using Visual Studio 2008.) ...

What are the main benefits of implementing a virtual machine as part of an application?

Several databases I've been looking at recently implement a virtual machine internally to perform the respective data reads and writes. For an example, check out this article on SQLite's virtual machine they call the 'VDBE'. I'm curious as to what the benefits of such an architecture are. I would assume performance is one but why would a...

Why does my finite state machine take so long to execute?

Hello all :) I'm working on a state machine which is supposed to extract function calls of the form /* I am a comment */ //I am a comment pref("this.is.a.string.which\"can have QUOTES\"", 123456); where the extracted data would be pref("this.is.a.string.which\"can have QUOTES\"", 123456); from a file. Currently, to process a 41kb fil...

Asynchronous Completion Routines I/O, Pointer to routine encapsulated in class

I was wondering if there was anyway to use functions like ReadFileEx that require a pointer to a function in a class WITHOUT marking the function as static? Thanks in advance. SBP. ...

Is It Safe to Cast Away volatile?

Most of the time, I am doing this way. class a { public: ~ a() { i = 100; // OK delete (int *)j; // Compiler happy. But, is it safe? // The following code will lead compilation error : delete j; } private: volatile int i; volatile int *j; }; int main() { a aa; } ...

What is a thread pool in C++ and how it is implemented?

HI I just came across a new term thread pool. I don't know what it is, can any body offer some information about this? What it is a thread pool and how it is implemented? Is a thread pool just a collection of thread? ...

functor returning 0

I've recently started teaching myself the standard template library. I was curious as to why the GetTotal() method in this class is returning 0? ... class Count { public: Count() : total(0){} void operator() (int val){ total += val;} int GetTotal() { return total;} private: int total; }; void main() { set<int> s; ...

C++ in embedded software programming

Hello, Is there significant problem, if I write the code for embedded linux system using C++ language programming ?. Actually, I have intention to port some code to arm linux, with arm-uclibc compiler. Thanks ...

Exception in Memset

When try to do a memset it gives the following exception "Unhandled exception at 0x1023af7d (PxSmartInterface.dll) in SendOutDllTestExe.exe: 0xC0000005: Access violation writing location 0x40e3a80e." My memset statement will look like this memset(lpStatus, 0, csStatus.GetLength()); ...

right usage of std::uncaught_exception in a destructor

There are some articles concluding "never throw an exception from a destructor", and "std::uncaught_exception() is not useful", for example: http://www.gotw.ca/gotw/047.htm (written by Herb Sutter) But it seems that I am not getting the point. So I wrote a small testing example (see below). Since everything is fine with the testing ...

Monitoring CPU and disk utilization of a single program

How can I calculate CPU and disk utilization of another concurrent program? I.e. one program is running and other calculates the first's resource use. I'm using C and C++ and running under Windows XP. ...

VC++ libcurl .lib size

I'm having an issue with the size of the .lib when I compile libcurl. It's 1.6 MB and the sample program they have is alround 300 KB. I downloaded the latest version (curl-7.20.0) and opened the project file from the lib directory in visual studio 2008. In the project properties I set /MT and compiled a release build. I even tried addi...

How to achieve the following C++ output formatting?

I wish to print out double as the following rules : 1) No scietific notation 2) Maximum decimal point is 3 3) No trailing 0. For example : 0.01 formated to "0.01" 2.123411 formatted to "2.123" 2.11 formatted to "2.11" 2.1 formatted to "2.1" 0 formatted to "0" By using .precision(3) and std::fixed...

C++ brain teaser

I recently refactored code like this (MyClass to MyClassR). #include <iostream> class SomeMember { public: double m_value; SomeMember() : m_value(0) {} SomeMember(int a) : m_value(a) {} SomeMember(int a, int b) : m_value(static_cast<double>(a) / 3.14159 + static_cast<double>(b) / 2.71828) {} }; class MyClass ...

Accessing program information that gdb sees in C++

I have a program written in C++, on Linux, compiled with -g. When I run it under gdb, I can 1) set breakpoints 2) at those breakpoints, print out variables 3) see the stackframe 4) given a variable that's a structure, print out parts of the structure (i.e. how ddd displays information). Now, given that my program is compiled with "-g...