c++

C++ To .Net

Hello, I'm learning C++, but i see that .Net is a very nice framework, then i want to ask: "It's difficult to develop in .Net?", remember that i have some knowledge of VB and Delphi. I'm using Windows Vista Ultimate. Thanks! ...

msvcr90d.dll not found in debug mode

I found MSVCR90D.dll not found in debug mode with Visual C++ 2008 question but none of given answers really gives answer to the question. Most of them point to turning off incremental linking but don't explain the true cause of the error and how it can be fixed without turning off incremental linking. I'd like to mention that my situati...

trouble deleting keys/values on STL hash_map when duplicate keys

I am using C++ hash_map to store some C-style string pairs. And all keys should be unique for this case... My problem is a serious memory leak when stress testing this over mutliple runs. When none of these keys in the test are not identical, there is no memory leak. But with identical keys its a different story... The hash_map (this...

How can I make an instance of my singleton const?

Hello, I'm trying to make a wrapper for Ogre (an open source 3D engine) 's standard logging class. I want it to have the same syntax as std::cerr, and also output to cerr when running on Linux. Here's what I have: #ifndef _LOGGER_H_ #define _LOGGER_H_ #ifndef _XSTRING_ #include <xstring> #endif #ifndef __LogManager_H__ #inclu...

Compiling differences in Visual C++ and *nix enviroments

Is there a difference between compiling projects in *nix enviroments and MS Visual C++? For example, there is a "stdafx.h" file in Visual C++. The reason I'm asking is that I submitted a piece of code which compiled in g++, to refactormycode.com. Then after it got a refactoring, it seemed to include a "stdafx.h", so I figured I'll down...

g++ generated Assembly looks ugly !

Hello all, I'm quiet familiar with gcc assembly... Recently I was forced to turn back to g++ for some codes clean up. Let me mention I'm too much familiar with assembly, hence, for some curiosity purposes, I often get a look at how good the compiler generated asm is. But the naming conventions with g++ are just bizaare. I was wondering...

Method of storing a date

I was wondering if there is a way to get a date without writing your own function. Something such as accessing the date set for the system. I tried char dateStr[9]; _strdate(dateStr); with the included time header, but I got compiler error ISO C++ forbids declaration of _strdate with no type. I thought _strdate was already declared an...

Interaction between DLLs

Hello everyone, I have a DLL, say A, which implements general algorithms to solve mathematical equations. I have another DLL, say B, which implements mathematical equations DLL B uses DLL A in order to solve it’s equations but DLL B must be able to execute a given equation from DLL A (DLL A implements some numerical, proximity methods a...

What did QWidget* QApplication::mainWidget() become in Qt4?

I am porting an application from Qt3 to Qt4, and need a Qt4 replacement for QApplication::mainWidget() which used to return the top-level widget in Qt3. Does anyone know how to do this in Qt4? ...

Binary version of iostream

I've been writing a binary version of iostreams. It essentially allows you to write binary files, but gives you much control over the format of the file. Example usage: my_file << binary::u32le << my_int << binary::u16le << my_string; Would write my_int as a unsigned 32-bit integer, and my_string as a length-prefixed string (where the...

C++ Beginner question: Constructor

Hi I just came across the following source code of an constructor. testProg::testProg() : CCProg() { m_UID = n_UID = 0; } Normally, an constructor looks as follows according to my understanding: testProg::testProg() { m_UID = n_UID = 0; } So I am wondering what is the purpose of this CCProg(), would be great if ...

boost::shared_ptr and multithreaded access

Hi! I'm trying to implement a multithreaded framework, in which output objects are created at the end of every frame that my networking thread runs, so that another thread can, at the beginning of its frame, obtain the most recent "completed output" pointer and know that it has safe and complete read-only access to any data stored withi...

Operator Overloading for Objects in Multiple Classes

So can you overload operators to handle objects in multiple classes (specifically private members.) For example if I wanted == to check if a private member in Class A is equal to objects in a vector in Class B. For example: bool Book::operator==(const Book& check){ return(((ISBN1 == check.ISBN1) && (ISBN2 == check.ISBN2) && (ISBN3 =...

pthread Function from a Class

Lets say i have a class such as class c{... void *print(void *){ cout << "Hello"; } } And then i have a vector of c vector<c> classes; pthread_t t1; classes.push_back(c()); classes.push_back(c()); Now i want to create a thread on c.print(); And the Following is Giving me problem pthread_create(&t1, NULL, &c[0].print, NULL); ...

C++ Auto Class Implementation in Editor

Much of my time spent developing C++ applications is wasted implementing class definitions. By that I mean the prototyping of classes then creating their respective implementations. For example: #ifndef FOO_H #define FOO_H class Foo { public: Foo (const X& x, const Y& Y); ~Foo (); void PerformXYZ (int Count); }; #endif An...

Fast Bitwise Question in C++

Hello all :) I'm looking for a fast way to setup a method of returning a bitmask based on a number. Basically, 4 one bits need to be emitted pre number input. Here's a good idea of what I mean: foo(1); // returns 0x000F foo(2); // returns 0x00FF foo(3); // returns 0x0FFF foo(4); // returns 0xFFFF I could just use a big switch statemen...

Is there any automated way to implement post-constructor and pre-destructor virtual method calls?

Hi all, Due to the well-known issues with calling virtual methods from inside constructors and destructors, I commonly end up with classes that need a final-setup method to be called just after their constructor, and a pre-teardown method to be called just before their destructor, like this: MyObject * obj = new MyObject; obj->Initiali...

Is C++ worth investing time in learning?

With languages like C# that can basically do anything, I found a drawback that could not be the case in the future, and that is the lack of many open source 3rd party libraries that are well documented to choose from. However with C++, there are many libraries to choose from, and this is a big pro for me. One thing I want to get into is ...

stringstream extraction not working

I seem to be having a problem with extracting data from a stringstream. The start of my extraction seems to be missing the first two characters. I have something similar to the following code: std::stringstream ss( std::stringstream::in | std::stringstream::out ); bool bValid; double dValue; double dTime; for( ...

How to calculate determinant matrix with lapack++ (2.5+)

What is the best (fastest) way to calculate the determinant of a (non symmetric, squared) LaMatGenDouble matrix with the lapack++ library? ...