c++

(C++)Code::Blocks possible wrong setup for Qt4

OS : windows xp SP2 , compiler : Code::Blocks ver. 10.05 , Qt 4.6 I recently started to learn Qt. At first all went well with simple tut examples. I soon came across an example that can not compile and and realized that something is wrong. Here is the code : #include <QWidget> #include <QApplication> #include <QPushButton> #include ...

How should I profile visual c++ express?

I've read a lot of the posts here giving profiling advice but I need to ask this. From what I can tell, visual c++ express doesn't generate a debugging file that is used by profiler programs. I tried AMD Codeanalyst and it seemed to work fine except none of the routines in my program were identified. -just a lot of "unidentified mod...

C++ Builder onResize event after exit

I wrote some program in C++ Builder 6 (don't ask me why). I do some actions with on-form components after formResize event occurs. But it occurs right after I close my program, and looks like all components on form where deleted, so I've got exception and everything crashes. There is my code: void __fastcall TForm3::FormResize(TObject *...

Get USB serial number c++

I'm looking to retrieve the serial number from a USB memory stick on windows in c++. I have found plenty of C# examples, and c++ for linux but none for c++ and windows. Edit C++/CLI is not an option unfortunately. I am looking for the serial number of the device not the file system. OR "Device Instance Path" AKA "InstanceID" ...

Protocol Buffer and UTF16 Unicode.

How do you use Google Protocol Buffer with UTF16 Unicode? ...

Need a C++ library to convert excel files from 1995 to new ones

Hi, I was wondering if anyone knows of a C++ utility that can convert a 1995 .xls file (Microsoft Excel v7.0) into an excel file form 1997 or later. It doesn't need to be free. thanks ...

How can I make a std::list of arrays?

I would like to make an std::list of arrays. specifically, I want a list of arrays of Borland Code Builders AnsiStrings. the real kicker being that I would like the arrays to be allocated dynamically. How do I define the list? Im so lost here i dont know were to begin. std::list<???> myList; What am I putting inside the angle brack...

vector of double[2] error

...

Exporting global variables from DLL

I'm trying to export a global variable from a DLL. Foo.h class Foo { public: Foo() {} }; #ifdef PROJECT_EXPORTS #define API __declspec(dllexport) #else #define API __declspec(dllimport) #endif API const Foo foo; Foo.cpp #include "Foo.h" const Foo foo; When I compile the above code, Visual Studio complains: foo....

What happens when C++ reference leaves it's scope?

If I interpret C++ references correctly, they are like pointers, but with guaranteed data integrity (no NULL, no (int*) 0x12345). But what happens when scope of referenced object is leaved? If there are no magic involved (and probably it is not), referenced object will be destroyed behind my back. I wrote a piece of code to check this:...

strange error in g++

My program has a class with a vector of Level objects named levels. In a member function there is this line: levels.push_back(level::Level()); I made several changes to my program today, and that line of code started segfaulting: 0x0804d248 in void std::vector<yarl::level::Level, std::allocator<yarl::level::Level> >::emplace_back<ya...

Compilation errors when inheriting PortableServer::RefCountServantBase.

I am working on a corba application where in create_servant() method we are creating new servant and returning it to the callee. To make the memory management easier, I am inheriting PortableServer::RefCountServantBase class to the implementation class. I get the below compilation errors. "simples.cpp", line 108: Error: Cannot crea...

how to call a method with string& parameter by using char*?

I have a C++ dll from other company. there is a method with a string& msg parameter, void methodA(string& msg); What I have now is a char* with length which is big enough to take the msg from methodA. I want to call methodA to get message back from methodA. Can I do it? how? thanks, ...

Adding ICO file to Win32 program

So added a resource.rc and a resource.h file to my project. resource.rc has #include "resource.h" IDI_MYICON ICON "my_icon.ico" and resource.h has #define IDI_MYICON 201 wincl.hIcon = LoadIcon (GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON)); wincl.hIconSm = (HICON) LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), ...

decltype and parenthesis

I don't understand the last line of the example on page 148 of the FCD (§7.6.1.2/4): const int&& foo(); int i; struct A { double x; }; const A* a = new A(); decltype(foo()) x1 = i; // type is const int&& decltype(i) x2; // type is int decltype(a->x) x3; // type is double decltype((a->x)) x4 = x3; // type is co...

const reference to temporary oddity

We all know that things like this are valid in c++: const T &x = T(); while: T &x = T(); is not. In a recent question the conversation lead to this rule. The OP had posted some code which clearly evokes UB. But I would have expect a modified version of it to work (This is the modified version): #include <iostream> using namespace...

Converting singleton classes to a type of context

I have been scratching my head for a while thinking about the best way to remove singletons I stupidly added in the first place. For background, this application is a stock portfolio tracker. I currently have three classes which I thought would be the only instance: Prices (a class holding a list of historical prices, dividends, spli...

Where to place file in order to read?

Hey, where do I place a text file that I'm trying to read using fstream? In this tutorial, http://www.gamedev.net/reference/articles/article1127.asp, they say ifstream fin("input.txt"); where would "input.txt" be located? Before I tried directing a path to the file by doing this "C:\Users\XXXXXXX\Documents\test.in". This however does n...

find most often seen string from a log file

hello guys, I want to find most often seen string in a huge log file. Can someone help me how to do this. one way to do this is to hash each and every string and count the maximum value but its not efficient. Are there any better ways to do this. Thanks & Regards, Mousey. ...

How can I determine the statistical randomness of a binary string?

How can I determine the statistical randomness of a binary string? Ergo, how can I code my own test, and return a single value that corresponds to the statistical randomness, a value between 0 and 1.0 (0 being not random, 1.0 being random)? The test would need to work on binary strings of any size. When you do it with pen and paper, y...