c++

How to Add New Members to Struct

These are functions and Struct declarations I have, and I'm not allowed to change them. DerivedA giveDerivedA (); DerivedB giveDerivedB (); struct Base{ QString elementId; QString elementType; }; struct DerivedA : Base { int a; int b; }; struct DerivedB : Base { int c; int d; }; But what I need is something ...

c++ qt dll not in good folder

I made an project in visual studio with QT, its something for in the taskbar with a tray icon. but on other pc's i didnt saw the icon because they dont have de qicon.dll file. the qicon.dll is in the folder: C:\Qt\4.6.3\plugins\imageformats but when i delete it there and i paste it at the exe location it dont work. how can i fix this? ...

MFC ugly menu font Windows 7

Hello, I'm writing an application using Visual Studio 2010 and MFC. When I create application with MFC wizard menu font is somehow ugly. Any ideas how to fix this? Here's an example and there seems to be the same ugly menu font. http://visualstudiomagazine.com/Articles/2010/06/01/~/media/ECG/visualstudiomagazine/Images/2010/06/0601vsm...

Need help with understanding compilation of C++ programs..

Hi, I don't properly understand compilation and linking of C++ programs. Is there a way, I can look at object files generated by compiling a C++ program(in an understandable format). This should help me understand format of object files, how C++ classes are compiled, what information is needed by compiler to generate object files and he...

how to get flash's url, height, width in a HTML web page?

I am new to Web C++ programming. I am trying to use IE8's IWebBrowser2 interface to obtain a webpage's embedded flash's url, height, width information. This flash can be generated by javascript. So I did like this: from IWebBrowser2 I got IHTMLElementCollection,then I iterated through the collection to get IHTMLObjectElement2,and finally...

how to get compile warning

I'm quite surprised when I compile the following code without any warning using g++ 4.1.2 with -Wall -Wextra -Wconversion enabled. I want g++ to show me every warning to avoid potential harm. I have to stick to g++ 4.1.2. #include <stdint.h> #include <string> using namespace std; int main() { uint8_t u1=1; uint64_t u64=1000; ...

Linux developers knowing C++?

I got into a discussion a while back. The company I work at develop under Linux and does so in ANSI C. A lot of benefits could come from moving to C++ as far as design goes I think. Our existing code would just have to get rid of all implicit type casts since C++ is a bit stricter about that and it would compile and run as usual. But I w...

std::vector<float> and double* - How safe is this?

Is it safe to do this? double darray[10]; vector<float> fvector; fvector.insert(fvector.begin(), darray, darray + 10); // double to float conversion // now work with fvector VS2008 gives me a warning about the double to float conversion. How do I get rid of this warning? I don't think it makes sense to cast darray to float* as that...

Usage of namespaces in c++

Can we use namespaces like in below snippet? The code compiles in both gcc and msvc, leaving me confused about namespace usage. In f1.h: namespace My { void foo(); } In f1.cpp ` void My::foo() { } I thought that the function should be defined as: namespace My { void foo() {} } Can anyone kindly explain? Thanks ...

How is the code memory managed?

When talking about a process' memory, I heard about things like code memory and data memory. And for the data memory, there are 2 major managing mechanisms, stack and heap. I am now wondering how is the code memory managed? And who manages it? Pardon me if my statement is not so clear. Thanks. ...

lambda expression (MSVC++ vs g++)

I have the following code #include <algorithm> #include <iostream> #include <vector> #include <functional> int main() { typedef std::vector<int> Vector; int sum=0; Vector v; for(int i=1;i<=10;++i) v.push_back(i); std::tr1::function<double()> l=[&]()->double{ std::for_each(v.begin(),v.end(),[&](int n){sum += n; /...

How to convert a unicode string to its unicode escapes?

Say I have a text "Բարև Hello Здравствуй". (I save this code in QString, but if you know other way to store this text in c++ code, you'r welcome.) How can I convert this text to Unicode escapes like this "\u1330\u1377\u1408\u1415 Hello \u1047\u1076\u1088\u1072\u1074\u1089\u1090\u1074\u1091\u1081" (see here)? ...

How does a compiled C++ class look like?

Hi all, With some background in assemble instructions and C programs, I can visualize how a compiled function would look like, but it's funny I have never so carefully thought about how a compiled C++ class would look like. bash$ cat class.cpp #include<iostream> class Base { int i; float f; }; bash$ g++ -c class.cpp I ran: bash$obj...

shared_from_this throws an exception

I am writing Qt-based app with Blender-like functionality. It consists of a 'framework' which is GUI + plugin system and plugins. Plugins are Qt dlls with objects (e.g. a Sphere, a Box, etc.) that can be basically created and displayed. All those objects, once created, are stored in the framework in some kind of a container structure whi...

Complex Mul and Div using sse Instructions

Is Performing Complex Multiplication and Division beneficial through SSE Instructions. I know that Addition and Subtraction does perform better in the SSE Land. Can some one tell me how I can use to perform complex multiplication to get a better performance. ...

Retrieve all the controls of any window with their types and value

My application is something like the Spy++ application: i want to be able to automatically retreive all the different controls of the active window (any application) and their children, and for each control i want to know the type, the name, and the value (caption or text). I am using a C# windows app. what is the solution to iterate ...

What is the most efficient way to make this code thread safe?

Some C++ library I'm working on features a simple tracing mechanism which can be activated to generate log files showing which functions were called and what arguments were passed. It basically boils down to a TRACE macro being spilled all over the source of the library, and the macro expands to something like this: typedef void(*TraceP...

Whats the significance of return by reference?

In C++, function() = 10; works if the function returns a variable by reference. What are the use cases of it? ...

Using openMP in the cuda host code?

It it possible to use openMP pragmas in the CUDA-Files (not in the kernel code)? I will combine gpu and cpu computation. But nvvc compiler fails with "cannot find Unknown option 'openmp' ", if i am linking the porgram with a opnemp option (under linux) A wayaround is to use openMP-statments only in c/c++ files. ...

string contains valid characters

I am writing a method whose signature is bool isValidString(std::string value) Inside this method I want to search all the characters in value are belongs to a set of characters which is a constant string const std::string ValidCharacters("abcd") To perform this search I take one character from value and search in ValidCharacter...