c++

WriteFile error #5 "denied access" under win Vista/seven

I googled a lot and I couldn't find any answer to this problem... I have a C++ console application that reads a 1GB SD card that fixes improperly closed files and writes the FAT table accordingly. The SD card is written at the beginning by a firmware in a custom made device. It worked OK up to Xp and stopped working in Win Vista/seven....

How to re-engineering design from source code using rational rose

I would like to create class diagram from existing source code using rational rose. I have VC++ 6 MFC project and I installed Rational Rose Enterprise Edition Version 2003.06.16. Now I would like to re-engineering the project to create design(class diagram) from the source code. Pls help me step-by-step process to do this, I couldn't ge...

How do I implement the equivalent of nested Perl hashes in C++?

I want to change some Perl code into C++. I need to know how to implement nested Perl hashes in C++. I thought of STL as a good choice and used maps. With the help of maps I can create only a simple hash but I do not know how to create a nested hash structure. My Perl hash is like this: %foo = ( "bar1" => { Default => 0, ...

name lookup of 'iter' changed for new ISO 'for' scoping

Hi, I'm trying to compile the two files below, but get an error message from the compiler: gcc 4.3.3 (Linux) The error is in the line signed with: LINE WITH ERROR What I'm I doing wrong, how should I change it? Luis ............................... $ g++ -c b.h b.cpp b.cpp: In function 'void calcularDesempPop(std::vector<Individuo, ...

Problem with leading zero's in a vector array of doubles

Hi, I'm tring to calculate the standard deviation of a vector of doubles (called A). Now I have a function called StDev that will do this. However, the first few elements of vector A are zero and I need to remove these. To do this I create a sub-array and then pass this to my StDev function as follows: std::vector<double> Array(f...

Why string string is allowed and int int is not allowed by Compiler?

Hi, I am just trying to check whether compiler allows type name as variable name. When i tried int int; It reported an error saying error C2632: 'int' followed by 'int' is illegal But when i tried #include <string> using namespace std; int main() { string string; } It didn't give any error. Both string and int are...

base class 'class std::vector<...>' has a non-virtual destructor

One of my C++ classes derives from std::vector so that it can act as a container that also perform custom actions on its content. Unfortunately, the compiler complains about the destructor not to be virtual, which I cannot change, since its in the standard library. Am I doing the whole thing wrong (thou shall not derive from STL) or is ...

constraints when dynamically loading a shared object from another shared object?

I'm dynamically loading (whith dlopen()) a shared object (named libprofile1.so) from main. In libprofile1.so I have defined factory function CreateProfile and class Profile. CreateProfile function creates an instance of Profile class and returns a pointer to it. Class Profile has a method pMethod. In main, after loading libprofile...

C++ string reassigned, is the old string correctly freed?

I have a c++ class with a member that is a string, something like: class Phone { string name; void foo() { name = string("new_name"); } } Now, within the function "foo", I reassign the string to "new_name". My question is: What happens to the old, empty string? Is it correctly "freed"? Does it still occupy memory? Now I ini...

C/C++ CGI on Embedded device, POST, GET, LOGIN?

Hi all, I have here a small embedded device with uClinux. There is a Boa web-server, that supports CGI scripts. I need to make basic dynamic pages. Requirements GET method for navigation POST method for forms LOGIN for authentication I found this page http://www.cs.tut.fi/~jkorpela/forms/cgic.html There is described how to implemen...

What are rvalues, lvalues, xvalues, glvalues, and prvalues?

In C++03, an expression is either an rvalue or an lvalue. In C++0x, an expression can be an: rvalue lvalue xvalue glvalue prvalue Two categories have become five categories. What are these new categories of expressions? How do these new categories relate to the existing rvalue and lvalue categories? Are the rvalue and lvalu...

Declare Before use in C++?

Following code does compile whereas name "aNumber" is not declared before use. class A { A() :aNumber(100) { } void foo() { aNumber = 0; } int aNumber; }; If above code compiles then why not following :- A. class Dummy { void foo(INT); typedef int INT; }; B.Default initializatio...

How pass data to 'generic' observer? As arguments or as a single struct?

I am busy adding a generic observer mechanism to a legacy C++ application (using Visual Studio 2010, but not using .Net, so .Net delegates are out of the question). In the design I want to separate the application-specific part as much as possible from the generic observer mechanism. The most logical way of implementing observers seems...

Excel RTD (Real Time Data) client other than Excel?

Hi everyone, I have been looking all over, and couldn't find any example for an RTD CLIENT (many RTD server samples, though). My goal is to 'pull' data from an RTD server into my application for algo-trading purposes. If possible, without using C# / .Net, as I am looking for a lightweight, deploy-able solution. Can you give me any ti...

WebView not showing in NSWindow

I am developing a C++ app and I need to display a NSWindow with a WebKit WebView inside it. I've coded up the Objective-C class which will manage creating and displaying the window but the WebView contained inside it does not display. Here is my code. Any idea on what is wrong and how I can fix it? I'm compiling the below code with $g++...

Is there a more efficient way to get the length of a 32bit integer in bytes?

I'd like a shortcut for the following little function, where performance is very important (the function is called more than 10.000.000 times): inline int len(uint32 val) { if(val <= 0x000000ff) return 1; if(val <= 0x0000ffff) return 2; if(val <= 0x00ffffff) return 3; return 4; } Does anyone have any idea... a cool bi...

Create Widget in QMainWindow and load to ScrollArea

Hey, I tried to create a Mainwindow with an slot, which creates a Widget and loads it to the ScrollArea in the Mainwindow. This doesn't work, so I tired to create the Widget in the constructor of the mainwindow and I always get errors and don't know why.. so what's the right declaration of the Widget? #include <QtGui> class Mainwindo...

How to draw a QPoint on a QGraphicsView/Scene

It's really not clear to me how to simply draw a 2d point in QT. I want it to overlay a QPixmap item, but every piece of documentation I find talks about drawing polygons with brushes. Thanks in advance - ...

Switch off highlighting "event" keyword in Visual C++

Hello! I have question: How to switch off highlight keyword "event" in Visual C++ 2010? I don't use .net , so for me it isn't keyword, and I would call it one variable "event". ...

Compile BADA Sample ApplictaionApp from command prompt command

Hello I am Compiling BADA sample appliction ApplicationApp but from command prompt.Now for thisi needed commands so i had a look at BADA IDE console while Building ApplicationApp.The command console showed for compiling was i686-mingw32-g++ -D_DEBUG -DSHP -DBUILD_DLL -I"C:/bada/1.0.0b3/include" -I"C:/bada/1.0.0b3/IDE/workspace2/Animatio...