c++

C++ to C# Translator.

i found a translator for c++ to c# , but it doesn't work. (Code2Code.net) Test with cout int main(int argc, char** argv) { cout << "Hello World"; return 0; } The Results becomes public static int Main(string [] argv) { cout << "Hello World"; return 0; } My Question to you, is = is it any other translator that works for C++ t...

where is this defined?

Attempting to disable BSTR caching: SetOaNoCache(); VC++ compiler build output: 'SetOaNoCache': identifier not found Don't want to use: OANOCACHE=1 Question: Where is SetOaNoCache defined - header file? ...

Why does (int)55 == 54 in C++?

So I'm learning C++. I've got my "C++ Programming Language" and "Effective C++" out and I'm running through Project Euler. Problem 1...dunzo. Problem 2...not so much. I'm working in VS2008 on a Win32 Console App. Whats the Sum of all even terms of the Fibonacci Sequence under 4 million? It wasn't working so I cut down to a test c...

How do I print a double value with full precision using cout?

So I've gotten the answer to my last question (I don't know why I didn't think of that). I was printing a double using cout that got rounded when I wasn't expecting it. How can I make cout print a double using full precision? Thanks ...

Where is Round() in C++?

Duplicate of: round() for float in C++ I'm using VS2008 and I've included math.h but I still can't find a round function. Does it exist? I'm seeing a bunch of "add 0.5 and cast to int" solutions on google. Is that the best practice? ...

Does this C++ class containing a variable size array use dynamic memory allocation?

Does doing something like this use dynamic memory allocation? template <class T, int _size> class CArray { public: ... private: T m_data[_size]; }; Can someone explain to me what's going on behind the scenes when I create the object? CArray<SomeObject, 32> myStupidArray; ...

Call function in c++ dll without header

Hello, I would like to call a method from an dll, but i don't have the source neither the header file. I tried to use the dumpbin /exports to see the name of the method, but i can found the methods signature? Is there any way to call this method? Thanks, ...

C++ serialization of complex data using Boost

Hi, I have a set of classes I wish to serialize the data from. There is a lot of data though, (we're talking a std::map with up to a million or more class instances). Not wishing to optimize my code too early, I thought I'd try a simple and clean XML implementation, so I used tinyXML to save the data out to XML, but it was just far to...

What is the best way to learn C++ if I have a bit of other programming experience?

Just would like some thoughts of what you think about my strategy to learn C++. While I understand that it takes years to master a programming language, I simply want to get to the point where I can be considered competent as quickly as possible. Why quickly? Well when I say quickly I'm really saying I'm committed, and that I don't want ...

Boost exception at runtime

Hi, Using this code: #include <fstream> #include <boost/archive/text_oarchive.hpp> using namespace std; int main() { std::ofstream ofs("c:\test"); boost::archive::text_oarchive oa(ofs); } I'm getting an unhandled exception at runtime on executing the boost archive line: boost::exception_detail::clone_impl<boost::except...

Using "this" as a parameter to copy constructor

I have a c++ class, let's say it's called c, and I want to use the implicit copy constructor in one of the methods, like this: c c::do_something() { c copy = this; //I want implicit copy constructor here! copy.something_else(); //........// return copy; } However, gcc returns this error: error: invalid conversion from 'c*...

using string iterators over char* in boost regex

I am trying to search a char* to find matches and store each match as a struct using boost regex. I do not know how to use the std::string iterators over char*. So I created std::string from char* and using them. But now I want pointers in the original char* which can only be found using std::string I created. See the following code. The...

Thread communication theory

What is the common theory behind thread communication? I have some primitive idea about how it should work but something doesn't settle well with me. Is there a way of doing it with interrupts? ...

Check for valid image

I'm writing a program that downloads information from the web and part of that is images. At the moment I'm having a problem as the code to download the images is a different part to the code that displays them (under mvc). If a 404 is issued or the image download fails some way the display code pops a message propmt up which i would l...

Templates: Use forward declarations to reduce compile time?

I have to deal with a library that consists of many templated classes, which are of course all implemented in header files. Now I'm trying to find a way to reduce the unbearably long compile times that come from the fact that I pretty much have to include the whole library in each and one of my compilation units. Is using forward declar...

C++ alternative tokens?

I've just read this nice piece from reddit. They mention "and" and "or" being "Alternative Tokens" to && and || I was really unaware of these just till now. Of course, everybody knows about the di-graphs and tri-graphs but "and" and "or"? Seriously? Since when? Is this a recent addition to the standard? I've just checked it with Visua...

Constructor doesn't work for class inherited from std::string

when doing #include <string> class MyString : public std::string { public: MyString() {} }; But the usage below: MyString s = "Happy day"; MyString s("Happy Day"); MyString s = (MyString)"Happy day"; neither of them works. It seems that there's something to do with constructors/operators declaration/overridding, but can ...

nested classes and references to outside classes (c++)

This is quite straightforward - gcc fails to to compile this sample code (c++). class myclass { struct mystruct { myclass something; int something_else; }; }; It tells me, that Field 'something' has incomplete type. I probably miss something trivial, because I'm quite new in c++, but why can't I make nested cla...

multidimensional character array question

how do you initialize and uninitialize a multidimensional character array in C++? ...

Reconciling classes, inheritance, and C callbacks

In my C++ project, I've chosen to use a C library. In my zeal to have a well-abstracted and simple design, I've ended up doing a bit of a kludge. Part of my design requirement is that I can easily support multiple APIs and libraries for a given task (due, primarily, to my requirement for cross-platform support). So, I chose to create an ...