c++

cmath Errors when using FLTK

For some reason, whenever I add the FLTK directory to my include path, I get a bunch of errors from cmath. I am using GCC version 4.2. Here is a sample program and the build output: main.cpp #include <cmath> int main() { return 0; } **** Build of configuration Debug for project CMath Test **** make -k all Building file: .....

How many threads does it take to make them a bad choice?

I have to write a not-so-large program in C++, using boost::thread. The problem at hand, is to process a large (maybe thousands or tens of thousands. Hundreds and millons are a possibility as well) number of (possibly) large files. Each file is independent from another, and they all reside in the same directory. I´m thinking of using th...

getpeername() doesn't work with connections to localhost

EDIT: Restating the problem, if I am listening to port 54321 and a local process listening to port 12345 connects to me, creating socket s, how do I actually find the port it is listening on? sockaddr_in addr; int len = sizeof(addr); getpeername(s, (sockaddr*)&addr, &len); cout << string(inet_ntoa(addr.sin_addr)) << ":" << ntohs(addr.si...

best C++ command line argument parser

Possible Duplicates: What parameter parser libraries are there for C++? C++ Parse Command Line Arguments What is the best C++ command line argument parser that you can suggest? ...

Is there any relation between Virtual destructor and Vtable

If we write virtual function it adds a vtable in object of that class. Is it true for virtual destructor too ? Is vtable used to implement virtualness of destructor ...

What's your deep comprehension of pointer,reference and Handle in C,C++ and Java?

What's your deep comprehension of pointer,reference and Handle in C,C++ and Java? We usually think about the pointer,reference and Handle on the specify language level, it's easy to make confusion by the newbie like me. Actually all those concept in java, just a encapsulation of pointer. All pointer just a encapsulation of main memory...

destructors in Qt4

I'm very confused about using destructors in Qt4 and hope, you guys can help me. When I have a method like this (with "Des" is a class): void Widget::create() { Des *test = new Des; test->show(); } how can I make sure that this widget is going to be deleted after it was closed? And in class "Des" i have this: Des::Des() { ...

Std::vector is initialized to garbage. Weird behavior. Any ideas on what's up?

My class has this member. std::vector<AvaWrapper> m_controls; In my constructor I call m_controls.clear() Then I call a member function that does m_controls.clear() again but it blows up with an assert. The debugger shows that m_controls has a half million or more entries though none of them are valid cause the debugger shows ...

Variadic function without specified first parameter?

Out of curiosity, I thought I'd try and write a basic C++ class that mimics C#'s multiple delegate pattern. The code below mostly does the job, with the nasty sacrifice of losing almost all type-safety, but having to use the initial dummy parameter to set up the va_list really seems a bit off. Is there a way to use va_list without this? ...

How to register form for WM_DEVICECHANGE message in windows mobile

Hi.. i am using c# .net 3.5 compact framework to write code.. please can any one tell me how do i register a form for WM_DEVICECHANGE and how to handle that message in windowproc.. if i do this i get intimation of device hardware change.. i m not getting how to write please tell. Thanks ...

Boost advocacy - help needed.

Possible duplicates Is there a reason to not use Boost? What are the advantages of using the C++ BOOST libraries? OK, the high-level question is "Please provide me with what you consider to be the most effective arguments of why entire Boost, or some specific parts of it, should be compiled on our company's system and endorsed i...

C++ Win32 keyboard events

I am working on my keystroke logger for personal interest and asked a question related to this about yesterday; While loop using a lot of CPU. The issue with the program was that it took too much CPU Usage, and people have suggested to make the inputs key-event based. Since I'm new to the Win32 API, I try to look for references and tut...

Virtual inheritance - gcc vs. vc++

Hi all! I have a problem with Visual Studio 2008 concerning virtual inheritance. Consider the following example: #include<iostream> class Print { public: Print (const char * name) { std::cout << name << std::endl; } }; class Base : public virtual Print { public: Base () : Print("Base") {} }; class A : ...

[sqlite/C++] Saving to disk an in-memory database

I made a database through sqlite in c++. The db has been created in memory (using the ":memory:" parameter insted of a filename), in order to have a very quick behavior. The database is created by the following lines: sqlite3* mem_database; if((SQLITE_OK == sqlite3_open(":memory:", &mem_database)){ // The db has been correctly cr...

Specification on C++ and C#?

If you want to read the "source" of a language in C you go to C Programming Language by Kernighan; Ritchie; 0131103628 And in Java you read Goslings The Java(tm) Language Specification; 0321246780 But what do you read if you want to read a good book about the "specs" on C++ and C#? ...

Is it possible to use Qt threading without inheriting any Qt object?

The only way to enable threading demonstrated in qt documentation is through inheriting QThread and then override its run() method. class MyThread : public QThread { public: void run(); }; void MyThread::run() { QTcpSocket socket; // connect QTcpSocket's signals somewhere meaningful ... socket.connectToHos...

Windows Limited User Installation

I have a Win32 application that includes an EXE, an ActiveX control (DLL) and a COM server (EXE) and I am using Inno Setup 5 to build my installer. Many of our customers use limited user accounts where the user has no admin rights and because the COM components require to be registered (which writes to HKEY_CLASSES_ROOT), my setup file ...

partially sort vector c++

Hello i Have a "vector of vectors" that looks something like this 3 1 2 0 77 0 3 1 2 44 1 0 3 2 29 3 0 1 2 49 I would like to sort them according to the last element in every row so that it would look like this in the end 1 0 3 2 29 0 3 1 2 44 3 0 1 2 49 3 1 2 0 77 Of course my real example is a lot more complex... but this is ba...

Help learning C++ on unix. OS, machine, books, IDE .. the whole caboodle!

Hi, I’m a C# and Java serverside windows programmer by day and want to learn C++ on Unix in my spare time. I have very limited knowledge of C++ (from my university days). I currently own a dell laptop running Vista. Should I create a dual boot system or buy a new machine? Which Unix OS should I go for? Which IDE should I use? …. Ne...

Writing to binary file in C++ and C#

Hello, I have 2 applications. One in C++ (windows) open a binary file and only reads from it, i use: fstream m_fsDataIN.open("C:\TTT", ios::in | ios::binary | ios::app); and the second application (is in C#) opens the file and writes to it. I use: byte[] b = ... //have a binary data System.IO.BinaryWriter bw = new System.IO.BinaryW...