c++

Need help appending one wchar_t to another! C++

I have tried wcscat() but i get a runtime access violation. wchar_t* a = L"aaa"; wchar_t* b = L"bbb"; wchar_t* c; c = wcscat(a, b); Can somebody tell me what is wrong here? Or another way to solve my problem? Thanks ...

How to determine whether a C++ template has specified method

Let's suppose I am writing a function template GCD which uses both operator/ and operator%. For some types, for example, complex numbers or polynomials both can be computed efficiently (i.e. when dividing polynomials you get remainder "for free"). So some of my class templates have divmod implemented, which returns a pair of quotient and...

how do I dynamically cast between vectors of pointers?

I have: class T {}; class S: public T {}; vector<T*> v; vector<S*> w; transform(v.begin(), v.end(), dynamic_cast_iterator<S*>(w.begin())); But, of course, dynamic_cast_iterator doesn't exist. ...

Sort a singly Linked list

The structure of the linked list is head.item = the number you want to sort head.next = the next item The only catch is that I need the singly linked list to sorted in constant space. ...

LSB AppChecker: GCC links against unused libraries

I'm checking the portability of a shared object (.so) with the LSB AppChecker. One of the problems it reports is that there is one external library (libm.so.6) that is not being used but is linked against anyways. How can I prevent GCC from linking to this unneeded library? EDIT: The output of the ldd command against my shared object i...

How can I build all with MSBuild from the command line?

Is this valid? MSBuild /t=all /configuration=all I want to build ALL configurations of all projects in a sln file, etc from the command line using MSBuild in Visual Studio 2008. I do not want to have to specify them when I call MSBuild, the sln/proj files all have that information. I don't want to change my build script if I add conf...

Operator Overloading.

I'm new to C++, this is my first week since the upgrade from fortran. Sorry if this is a simple question, but could someone help me with operator overloading. I have written a program which has two classes. One object contains a vector and two scalars, the other class simply contains the first object. In a test implementation of this...

Window Hooking Questions

Is am using this: SetWindowsHookEx(WH_CALLWNDPROC, ...); I can see the messages I want to process, but I want to prevent those message from reaching the target window. So I tried this: SetWindowsHookEx(WH_GETMESSAGE, ...); When I do this I can modify the message, and prevent the target window from processing it, but this hook doesn...

What's the best programming IDE for C++ or Mono under Ubuntu?

Hello, as the title says: what's your IDE of choice to program C++ or Mono under Ubuntu? Is Eclipse a viable way? Is MonoDevelop mature enough? How about other IDEs? ...

memcpy not doing as it is supposed to

I have this bit of code that is outputting the wrong results. #include <stdio.h> #include <string.h> int main() { unsigned char bytes[4]; float flt=0; bytes[0]=0xde; bytes[1]=0xad; bytes[2]=0xbe; bytes[3]=0xef; memcpy( &flt, bytes, 4); printf("bytes 0x%x float %e\n", flt, flt); return 0; } the output that I get ...

Open file by its full path in C++

Hello, I want the user to give me the full path where the file exists and not just the file name. How do I open the file this way? Is it something like this: ifstream file; file.open("C:/Demo.txt", ios::in); Because it doesnt seem to work..I think.. Thanks in advance, Greg ...

Fastest way to find the number of lines in a text (C++)

Dear all, I need to read the number of lines in a file before doing some operations on that file. When I try to read the file and increment the line_count variable at each iteration until i reach eof. It was not that fast in my case. I used both ifstream and fgets . They were both slow . Is there a hacky way to do this, which is also us...

SQLite3 - Cannot Open Database

I have the following code: #include <iostream> #include <string> #include "sqlite3.h" int main() { sqlite3* db; int rc = sqlite3_open("testing.db", &db); std::cout << rc << std::endl; std::cout << sqlite3_errmsg(db); std::cin >> rc; } When I run it, the program outputs "21" and "library routine called out of sequ...

type/value mismatch in template C++ class declaration

I am trying to compile the following code on Linux using gcc 4.2: #include <map> #include <list> template<typename T> class A { ... private: std::map<const T, std::list<std::pair<T, long int> >::iterator> lookup_map_; std::list<std::pair<T, long int> > order_list_; }; When I compile this class I receive the following messag...

The Pimpl Idiom in practice

There have been a few questions on SO about the pimpl idiom, but I'm more curious about how often it is leveraged in practice. I understand there are some trade-offs between performance and encapsulation, plus some debugging annoyances due to the extra redirection. With that, is this something that should be adopted on a per-class, or ...

WebKit or Gecko - which one is better for embedding in C++ app?

Hi Which one would you choose and why? I'd like to hear opinions from people having experience with embedding a web browser engine in C++ application. I should stress I need all features of web browser engine except rendering i.e. HTTP client, cookie handling, DOM style HTTP parser, JavaScript engine. How can one strip either WebKit or ...

Shell Icon Overlay (C#)

I need a method to create Icon Overlay's for Folders and Files in Windows XP/Vista, using C# or C++? Any examples? Thanks, -Sean! ...

How do i cause a qtabwidget instance to automatically resize when child tabs are added to it?

I am trying to get the QTabWidget automatically resized to fit the child tab when the child is added but have been unable to do so. I have created a form using Qt Designer and have inherited this using the single inheritance approach as follows. class MyWidget : public QWidget { Q_OBJECT public: MyWidget(QWidget *parent = 0); p...

Failing to use stl containers in templated functions/classes

When I try and compile the following code... #include <vector> template <class T> void DoNothing() { std::vector<T>::iterator it; } int main(int argc, char**argv) { return 0; } g++ says: test.cpp:5: error: expected `;' before ‘it’ And I don't understand why this is a problem. If I replace it with std::vector<int>::it...

Large initial memory footprint for native app

Hi, I've noticed that the native C++ application I'm working on has quite a large memory footprint (20MB) even before it enters any of my code. (I'm referring to the "private bytes" measure in Windows, which as I understand it is the most useful metric). I've placed a break point on the first line of the "main()" function and sure en...