c++

C++ copy constructor a class that contains other objects

I know that the compiler sometimes provides a default copy constructor if you don't implement yourself. I am confused about what exactly this constructor does. If I have a class that contains other objects, none of which have a declared copy constructor, what will the behavior be? For example, a class like this: class Foo { Bar bar; }...

Finding a nonexisting key in a std::map

Is there a way to find a nonexisting key in a map? I am using std::map<int,myclass>, and I want to automatically generate a key for new items. Items may be deleted from the map in different order from their insertion. The myclass items may, or may not be identical, so they can not serve as a key by themself. During the run time of th...

My http server in c++ is not sending all files back correctly

I'm working on an HTTP server in c++, and right now it works for requests of text files, but when trying to get a jpeg or something, only part of the file gets sent. The problem seems to be that when I use fgets(buffer, 2000, returned_file) it seems to increment the file position indicator much more than it actually ends up putting into ...

Weird behaviour of custom C# bindings, they run only on my dev environment, nowhere else!

Hello, following my post "Writing a C++ DLL, then wrapping it in C#.", i managed to create a C++ DLL and wrap it in C#, and everything works smooth... Well, only on my dev machine. While the code compiles on other machines too, i just won't run. Some background. I create a dll that uses cvblobslib that is based on opencv. I compiled all...

Is a wide character string literal starting with L like L"Hello World" guaranteed to be encoded in Unicode?

I've recently tried to get the full picture about what steps to take to create plattform independent C++ applikations that support unicode. A thing that is confusing to me is that most howtos and stuff equalize the character encoding (i.e. ANSI or Unicode) and the character datatype (char or wchar_t). As far as I've learned so far these ...

basic C++ question

I see in a class notices of a friend this: void show_results(Book& foreign_books) { int total_books total_books = foreign_books.getBooksNumber(); cout << total_books << endl; } this is a good class definition? class Book{ public: Book(); int getBooksNumber(); }; ps: i've writin...

What to look for in a candidate with over 8 years of experience in C, C++, Linux Application Development?

I need to interview a candidate with over 8 years of experience in Linux using C/C++. What would be the best way to judge such a candidate? Do I need to test his understanding of algorithms? Do I need to test his programming skills by asking to write a program? How should I test his understanding of Linux? ...

C++ serialization library that supports partial serialization?

Are there any good existing C++ serialization libraries that support partial serialization? By partial serialization I mean that I might want to say, save the values of 3 specific members, and later be able to apply that saved copy to a different instance, only updating those 3 members and leaving the others intact. This would be useful ...

Library for software mixing of sound (wave) streams

I would like to mix several sound (wave) streams into one. Each stream might have a different format (bits/sample, channel count, etc.), so conversion is needed also. I am looking for a library to do this, which I can link into my VS C++ project, before jumping in and implementing my own. ...

breakpoints in GDB

Hi all, I think this may have been asked earlier but i can't find one that satisfied my requirements. I am debugging(infact trying to understand) a large project by trying to analyze the code flow in various testsuites. But when i try to set breakpoints at some files, i get the error "no source file named filename found". So my quest...

Am I incorrectly using atoi?

I was having some trouble with my parsing function so I put some cout statements to tell me the value of certain variables during runtime, and I believe that atoi is incorrectly converting characters. heres a short snippet of my code thats acting strangely: c = data_file.get(); if (data_index == 50) cout << "50 digit 0 = '" << c <<...

[C++] gdb shows gibberish values for class members, despite working code

I ran in to a (in my eyes) very strange issue with gdb today, while trying to write a more C++-ish version of the reverse() method of my string class (all for learning, of course). Despite having a proper default constructor that initializes all member variables to 0, they start out as gibberish inside the member reverse() - according to...

Memorable 32-bit value as a constant

I am looking for a memorable 32-bit value to be used as a constant. If possible, it should be somewhat funny too. So far, I have come up with these two: 0xcafebabe 0xdeaddad Can you please suggest some other too? Thank you. ...

c++ templated friend class

Hello all, I'm trying to write an implementation of a 2-3-4 tree in c++. I'm it's been a while since I've used templates, and I'm getting some errors. Here's my extremely basic code framework: node.h: #ifndef TTFNODE_H #define TTFNODE_H template <class T> class TreeNode { private: Tre...

C++ ... # include <sys/mman.h>

Hi ; I am using Code::Blocks 8.02 and I have a question .. every time I try to compile minimad.c (the example that comes with Libmad) I get an error message : sys/mman.h: No such file or directory and of course a bunch of errors to follow :( I already know that its the memory management library ... The question is: Where can I download...

C++ returning nested class with template on base class problem

I am trying to create a list object, with the iterator class nested inside to understand how it works. In some method, I am trying to return an iterator object but it doesn't work. I created an example to show the problem : // CLASS A template <class T> class A { public: class B; A(){} }; // CLASS B template <class T> cla...

C++: Iterating through a vector of vectors

Hey there! I'm doing this project and right now I'm trying to: create some of objects and store them in vectors, which get stored in another vector V iterate through the vectors inside V iterate through the objects inside the individual vectors Anyway, I was just searching the web and I came accross the stl for_each function. It seem...

Overloading operator<< for a templated class

Hello! I'm trying to implement a method for a binary tree which returns a stream. I want to use the stream returned in a method to show the tree in the screen or to save the tree in a file: These two methods are in the class of the binary tree: Declarations: void streamIND(ostream&,const BinaryTree<T>*); friend ostream& operator<<(ost...

Is there an easy way to tell if a File stream has opened a directory instead of a file?

Hi, I'm making an HTTP server and when I get the path of the file they request I open it with the following: returned_file = fopen(path, "r"); this (contrary to what I would think) succeeds even if the path is a directory. Is there an easy way to check if the returned_file stream is a directory instead of a file? ...

Recommendations for naming C# classes/methods intended to replace existing APIs.

Long explanation aside, I have a situation where I need to basically re-implement a .NET framework class in order to extend the behavior in a manner that is not compatible with an inheritance or composition/delegation strategy. The question is not a matter of whether the course of action I am to take is what you would do, or recommend, i...