c++

How to convert a string representing decimal number in exponential form to float in Qt?

I have some decimal numbers in a text file represented in exponential form Eg: 144.2e-3. I want to store the values in float. In qt it returns "0" when i directly use the "number.toFloat()" method. Please help. ...

How can I use C++ enum types like C# ?

How can I use C++ enum types like C# ? consider following definition in c++ : enum myEnum { A, B, C}; myEnum en = A; Now I want write line #2 as following line like C# : myEnum en = myEnum.A; ?? ...

What's better to use, a __try/__except block or a try / catch block?

Hi, I'm wondering which is the better way to catch exceptions that I throw: is it a __try / __except block or a try / catch block? I'm writing in C++ and the program will only be used on Windows, so portability is not an issue. Thanks! ...

Is it possible to *safely* return a TCHAR* from a function?

I've created a function that will convert all the event notification codes to strings. Pretty simple stuff really. I've got a bunch of consts like const _bstr_t DIRECTSHOW_MSG_EC_ACTIVATE("A video window is being activated or deactivated."); const _bstr_t DIRECTSHOW_MSG_EC_BUFFERING_DATA("The graph is buffering data, or has stopped bu...

How to create and initialize SAFEARRAY of doubles in C++ to pass to C#

My C# method needs to be invoked from C++ Originally my C# method takes a parameter of type double[], but when calling from C++ it becomes a SAFEARRAY In C++ I need to take data from an array of doubles, and populate a SAFEARRAY. I have not found any sample code to do this. Any help is appreciated ...

create many cpp files in one project

can you give me a few examples of how different cpp files are communicated in one main cpp, in c++? ...

On what platforms will this crash, and how can I improve it?

I've written the rudiments of a class for creating dynamic structures in C++. Dynamic structure members are stored contiguously with (as far as my tests indicate) the same padding that the compiler would insert in the equivalent static structure. Dynamic structures can thus be implicitly converted to static structures for interoperabilit...

Working around the C++ limitation on non-const references to temporaries

I've got a C++ data-structure that is a required "scratchpad" for other computations. It's not long-lived, and it's not frequently used so not performance critical. However, it includes a random number generator amongst other updatable tracking fields, and while the actual value of the generator isn't important, it is important that th...

inheritance problem

I've messed up something. Here is the code: #include <iostream> class connection_c { private: std::string data_; void (*saveCallBack_)(); public: connection_c(std::string &data) : data_(data) { std::cout << "ctor: " << __FUNCTION__ << ":" << data_ << std::endl;} void registerCallBack(void(*cb)()) { saveCallBack_ = c...

Is it possible to change the tick count value returned from GetTickCount()?

I'm trying to do some testing and it requires the Windows system to be up and running for 15 Real-Time minutes before a certain action can ever occur. However, this is very time consuming to HAVE to wait the 15 real-time minutes. Is there a way to change the value GetTickCount() returns so as to make it appear that the system has been r...

Program is skipping over Getline() without taking user input

This is a very strange problem, when my program asks the user for the address, instead of waiting for input, it seems to skip the getline() function completely Answerinput: cout << "would you like to add another entry to the archive? (Y/N):"; cin >> answer; cout << endl; cout << endl; answer = toupper(answer); switch(answer) ...

adding to the windows explorer recognized locations

In Windows Explorer, if I type in certain strings in the address bar, it will recognize them and auto-complete them and go to those special locations. For instance: Public Music My Documents Recycle Bin My question: is there a way for my application to add its own recognizable string there? ...

creating objects in c++ not using "new"

hey, i want to make a program that lets say represents a matrix now the matrix will be represented by a vector that each object in the vector will represent a cell example: vector now when constructing the matrix the constructor recives a list of cells to insert in the matrix. the size of the list is unknown in compilation time i am ...

Are assignment operators not overloaded, when called upon pointers of a base class?

I have encountered the following problem which proved to me that I know far too little about the workings of C++. I use a base class with pure virtual functions class Base ... and a derived classes of type class Derived : public Base{ private: Foo* f1; ... Both have assignment operators implemented. Among other things, t...

Are there any performance penalties when using nested structures?

Are there any performance penalties when I use multiple nested structures/classes (kinda like using muti dimension heap arrays) or is it just an organizational feature of the language to make it easier to keep track of data and the compiler doesn't actually see any difference? Thanks ...

Eclipse CDT vs NetBeans C++ vs ...

Possible Duplicate: Best C++ IDE or Editor for Windows Hello, everyone. For a long time now, for C/C++ development, I have been using Notepad++ and the command line for compiling C/C++ programs. Now, I want to start using an IDE, and I have tried out quite a few. Currently, I am thinking of either Eclipse CDT or Netbeans C++,...

C++: How to prevent "potentially uninitialized warning" if im sure its not uninitialized?

Im getting this warning even though theres no possibility that it would remain uninitialized. The Visual Studio 2008 compiler fails to detect this. How do i suppress this warning at this piece of code only? ...

How do I assign a literal chinese string to a wchar_t* in visual studio(c++)?

I am trying to compile the following code in my test application on windows in visual studio for C++: const wchar_t* chinese = "好久不见"; But I get the following error: error C2440: 'initializing' : cannot convert from 'const char [5]' to 'const wchar_t * I am compiling with unicode, so I am confused about this. The error goes away...

Cross browser extension development in C++

Hi, I am starting to work on a browser extension and because of the nature of the extension I need to develop it in C++. I am currently working with Firefox but would like my code to be portable across browsers. First of all is there a library or an interface (like the NPAPI) that I can use to ensure this for extensions? What are the t...

Portable C++ approach to listing all adapter IPv4 addresses?

I want to generate the list of IP addresses on the local machine using C++. I looked at boost and it doesn't seem to have any function to do so. I need this because I want to see if the host name/IP address entered by the user is for the local machine. ...