c++

Interfaces in c++

I would like to use interfaces in c++ like in java or in c#. I decided to use purely abstract classes with multiple inheritance, but something is terribly wrong when I specialize the interface: class Interface { public: virtual int method() = 0; }; // Default implementation. class Base: virtual public Interface { public: virtual in...

How to trace a certain object in VC++ 6

Hello, i was wondering how to trace a certain object in VC++6. It can be done by tracing the unique object ID with "Trace Points", in more recent versions of visual studio. I still haven't figured out how to do this in VC++ 6. Maybe you guys can point me in the right direction. Thanks in advance! Best regards, zhengtonic ...

Capture CPU and Memory usage dynamically

I am running a shell script to execute a c++ application, which measures the performance of an api. i can capture the latency (time taken to return a value for a given set of parameters) of the api, but i also wish to capture the cpu and memory usage alongside at intervals of say 5-10 seconds. is there a way to do this without effecting...

Query on Static member variables of a class in C++

Sorry if this question seems trivial to many here. In a C++ code there is something as below: class Foo { public: static int bands; ... ... private: ... ... }//class definition ends int Foo::bands; //Note: here its not initialized to any value! Why is the above statement needed again when 'bands' is once declared in...

How to resolve this bad_alloc problem?

Hello, I'm developing an application that needs to interact over FTP. For this communication I am currently using C++, Visual Studio and Poco on Windows. The following line results in a bad_alloc exception... ftp = new FTPClientSession("127.0.0.1", 21); So I went down and tried initializing a StreamSocket first, also fails... Stream...

What does object* foo(bar) do?

For some class C: C* a = new C(); C* b(a); //what does it do? C* b = a; //is there a difference? ...

How to upload a file in C/C++ using HTTP with libcurl?

I would like to upload a fiel (a picture in my case) in C/C++ using HTTP with libcurl. It will be great to have a working sample in C/C++ with (optional) the php code for the server side. ...

Good, simple configuration library for large c++ project?

We are developing a rather large project in C++, where many components require configuration parameters. We would like to use a central place to configure everything (like a registry), preferably with a nice and simple GUI (e.g. like Firefox's about:config) and a simple API. I am pretty sure this that many applications have this kind o...

C# textbook for experienced C++ developers

[ This isn't Baked Potatoes - For Programmers, but it still might be deemed "not programming related" ] I've read through some of the recommendations at Can you recommend a good C# windows programming book (for Java developer), but none of those seem to be exactly what I'm looking for (perhaps because it doesn't exist). Specifically, I...

simple cout then cin allowing whitespace example?

Hello, Looking for a simple getline example which works correctly. I want to input something on the keyboard and assign it to a std::string, allowing for whitespace and tabs. The delimiter is the carriage return. TIA, Bert ...

Are there any articles or advice on creating a C++ chat server with a C# client?

My current class is planning on creating a basic networked game, but we have decided to take on the task of making a C++ server with a C# client. I understand this is probably a difficult task, but I was wondering if there is any advice on making this happen. I am sorry I do not have any more information than this. We are just getti...

What is the difference between "new" and "malloc" and "calloc" in C++?

What is the difference between "new" and "malloc" and "calloc" and others in family? (When) Do I need anything other than "new" ? Is one of them implemented using any other? ...

Efficient Huffman tree search while remembering path taken

As a follow up question related to my question regarding efficient way of storing huffman tree's I was wondering what would be the fastest and most efficient way of searching a binary tree (based on the Huffman coding output) and storing the path taken to a particular node. This is what I currently have: Add root node to queue while q...

When to use Malloc instead of New

Duplicate of: In what cases do I use malloc vs new? Just re-reading this question: http://stackoverflow.com/questions/807939/what-is-the-difference-between-new-and-malloc-and-calloc-in-c-closed I checked the answers but nobody answered the question: When would I use malloc instead of new? There are a couple of reasons (I can think ...

Is there a data structure that doesn't allow duplicates and also maintains order of entry?

Duplicate: http://stackoverflow.com/questions/769097/choosing-a-stl-container I'm looking for a data structure that acts like a set in that it doesn't allow duplicates to be inserted, but also knows the order in which the items were inserted. It would basically be a combination of a set and list/vector. I would just use a list/vector a...

member template specialization and its scope

It appears to me that C++ does not allow member template specialization in any scope other than namespace and global scope (MS VSC++ Error C3412). But to me it makes sense to specialize a base class's primary member template in the derived class because that is what derived classes do - specialize things in the base class. For instance, ...

C++: new call that behaves like calloc?

Is there a call I can make to new to have it zero out memory like calloc? ...

c++ Reading X bytes from std::cin, and truncating strings to X byte length

I have a c++ program that takes input from a linux pipe, and outputs to std::cout for further processing. Currently my code looks like this: std::istreambuf_iterator<char> it(std::cin); std::istreambuf_iterator<char> end; std::string str(it, end); //Lots of string manipulation here. str = str.substr(0, 65535); std::cout << str << std...

Is it safe to use -1 to set all bits to true?

I've seen this pattern used a lot in C & C++. unsigned int flags = -1; // all bits are true Is this a good portable way to accomplish this? Or is using 0xffffffff or ~0 better? ...

C++ Concurrent GET requests

I am writing a C++ application and would like to request several data files through a HTTP GET request simultaneously, where should I look to get started (needs to be cross-platform). Run Application Create a list of URLs { "http://host/file1.txt", "http://host/file2.txt", "http://host/file3.txt"} Request all the URLs simultaneously ...