c++

STL string comparison functor

Hi all! I have the following functor: class ComparatorClass { public: bool operator () (SimulatedDiskFile * file_1, SimulatedDiskFile * file_2) { string file_1_name = file_1->getFileName(); string file_2_name = file_2->getFileName(); cout << file_1_name << " and " << file_2_name << ": "; if (file_1_name <...

What unit testing tools are being used to test Rhapsody generated C++ code?

I am using the Rhapsody modeling tool to design multi-threaded C++ embedded applications. What unit testing approaches and tools are currently being employed for unit and functional test? Is anybody using the companion unit testing tool for Rhapsody (Test Conductor)? ...

Using a namespace twice

Hi, In c++ Is it OK to include same namespace twice? compiler wont give any error but still will it affect in anyway Thanks, EDIT: I meant using namespace std; // . . STUFF using namespace std; ...

Detecting endianness programmatically in a C++ program

Is there a programmatic way to detect whether or not you are on a big-endian or little-endian architecture? I need to be able to write code that will execute on an Intel or PPC system and use exactly the same code (i.e. no conditional compilation). ...

C++ - Undefined reference to a class recently created !

Hi, I just created this new class : //------------------------------------------------------------------------------ #ifndef MULTITHREADEDVECTOR_H #define MULTITHREADEDVECTOR_H //------------------------------------------------------------------------------ #include <vector> #include <GL/GLFW.h> //--------------------------------------...

How to define a function with same name which is present in different file

I want to define a class like this class HttpRestAccessor { public: IResource& UpdateResource(string& , IResource& ); }; and implementing in cpp file IResource& HttpRestAccessor::UpdateResource(string& resourceUri, IResource& resource) this cpp file refers to Winbase.h which has defined UpdateResource as follows #define Update...

Using CppUnit for memory leak detection

Is anyone aware of extensions to CppUnit that can be used to make assertions on a test by test basis concerning memory leaks. i.e. CPPUNIT_ASSERT_NO_LEAKS()? Essentially, I want to be able to fail specific tests when the execution of the test results in leaked memory. ...

Pointers in C# and how frequently it is used in the application?

For me , the Pointer was one of the hardest concept in programming languages in C++. When I was learning C++, I spent tremendous amount of time learning it. However, Now I primarily work in projects that are entirely written in languages like C#, and VB.NET etc. As a matter fact, I have NOT touched C++ for almost 4 years. Even though, C...

Linking C++ code with 'gcc' (without g++)

Hi all: quick question: I'm in a situation where it would be useful to generate my C++ executable using only 'gcc' (without g++). Reason for this is that I have to submit the code to an automatic submission server which doesn't recognize the 'g++' (or 'c++', for that matter) command. In my experiments, while I'm compiling gcc works well...

Options for a message passing system for a game

I'm working on an RTS game in C++ targeted at handheld hardware (Pandora). For reference, the Pandora has a single ARM processor at ~600Mhz and runs Linux. We're trying to settle on a good message passing system (both internal and external), and this is new territory for me. It may help to give an example of a message we'd like to pas...

Coding C++ without headers, best practices?

When i first learned c++, I had already coded in many other languages prior to it, which made the prospect of headers really depressing. So far, my solution to coding without header files in c++ has been far from optimal, limiting what I can do in the language. Is there any way to not have to write function declarations twice (headers) ...

Detecting AC Power connection in WinPE?

I'm trying to determine if a laptop is connected to AC power. The OS Im running under is WinPE. My app is written in native C++. WMI queries using Win32_Battery are not supported and the GetSystemPowerStatus API always returns '1' for ACLineStatus (running on AC power or not). Any ideas? Additonal investigation: Just tried the API '...

Sorting two linked lists according to memory location

I need to merge two doubly-linked lists, but not by their values (the lists are not sorted). I want to obtain a single list that has all the nodes from the two, but in the order in which they appear in memory. Maybe this image helps more: http://img140.imageshack.us/i/drawing2.png/ Is there any algorithm (preferably a fast one) that ca...

Screen capture from windows service

I've got DirectShow based screen capture software. Internally it calls CopyScreenToBitmap function to grab screen. Then the picture is compressed by ffdshow. It works fine as a desktop application, but as window service, on certain computers it does not work (black picture). I've set 'Allow service to interact with desktop' and run that ...

how can I write applications in C or C++ for Android?

I'm trying to develop/port a game to Android, but it's in C, and Android supports Java, but I'm sure there must be a way to get a C app on there, anyone knows of a good tutorial on the subject? Thanks! ...

How is C++'s multiple inheritance implemented?

Single inheritance is easy to implement. For example, in C, the inheritance can be simulated as: struct Base { int a; } struct Descendant { Base parent; int b; } But with multiple inheritance, the compiler has to arrange multiple parents inside newly constructed class. How is it done? The problem I see arising is: should the parents ...

How can I capture output from the Windows cmd shell?

Is there any way with, say Perl or PHP, that I can grab output from another process that outputs to the Windows cmd shell? I have a game server that outputs certain information, for example say 'player finished track in 43s' and I want to grab that line and use Perl or PHP to send a request to a webserver to update ranks on a web page. I...

Can I use the Curiously Recurring Template Pattern here (C++)?

I have a C++ application that can be simplified to something like this: class AbstractWidget { public: virtual ~AbstractWidget() {} virtual void foo() {} virtual void bar() {} // (other virtual methods) }; class WidgetCollection { private: vector<AbstractWidget*> widgets; public: void addWidget(AbstractWidget* widget) {...

What Windows C++ IDEs support the new C++0X standard?

What are excellent C++ IDE options that support the new standard c++0x (windows os friendly) besides visual .net 2010 (the beta is way too slow/clunky)? ...

Suggestions for brushing up on C++

I am looking for some suggestions for resources (preferably books) for brushing up on C++. I taught myself C++ in highschool, and also took an OOP course in university that covered C++ again (as well as Smalltalk); however, I have been primarily a PHP and Ruby on Rails developer for the past 8+ years, and while I consider myself to be ve...