c++

What's the difference between managed C++ and C#?

The major advantage I see for using C++ instead of C# is compiling to native code, so we get better performance. C# is easier, but compiles to managed code. Why would anyone use managed C++ for? What advantages it gives us? ...

C++, Embedded Linux, For Video HDMI Input/Output

Hello, This is a newbie question, but here we go... I would like to know how I would go about programming a small embedded linux board (I was thinking a TI Divinci based board) for a video input (via HDMI or Component) and then output to a TV (via the same HDMI connection). Along with the original video pass through, I would like t...

non-integral constants

I want a header file with a non-integral constant in it, e.g. a class. Note the constant does not need to be a compile-time constant. static const std::string Ten = "10"; This compiles but is undesirable as each compilation unit now has its own copy of Ten. const std::string Ten = "10"; This will compile but will fail with a linke...

C++ Resolve a host IP address from a URL

How can I resolve a host IP address, given a URL in Visual C++? ...

For C++ MacOSX app, what threading library to use?

I'm on MacOSX, writing an app in C++. What threading library should I use? pThreads? or is there something else? Thanks! ...

How do I force a particular instance of a C++ template to instantiate?

See title. I have a template. I want to force a particular instance of a template to instantiate. How do I do this? More specifically, can you force an abstract template class to instantiate? ...

Blowfish-encrypted messages between NSIS and PHP

For a project I'm working on, I need to encrypt and decrypt a string using Blowfish in a compatible way across NSIS and PHP. At the moment I'm using the Blowfish++ plugin for NSIS and the mcrypt library with PHP. The problem is, I can't get them both to produce the same output. Let's start with the NSIS Blowfish++ plugin. Basically t...

Why does autotools create project-File.o on one machine, File.o on another?

I have an autotools project. The same tarball on one machine compiles the files like this: gcc ... File.cpp -o project-File.o and on the other machine: gcc ... File.cpp -o File.o Does anyone know what causes this different behavior? Both machines are identically patched OS X, with the same tool versions. ...

Does Java have a const reference equivalent?

Here's a snippet of code: //Game board is made up of Squares. A player can place GamePieces on a Square. public class CheckersBoard { public boolean PlaceGamePiece(GamePiece gamePiece, int nRow, int nColumn) { return m_theGameBoard[nRow][nColumn].PlaceGamePiece(gamePiece); } private Squa...

How to forward declare a C++ class as inheriting from another class?

I know that I can forward declare a class as follows: class Foo; // ... now I can use Foo* However, can I do something like this: class Bar { public: virtual void someFunc(); }; // ... somehow forward declare Class Foo as : public Bar here someFunc(Foo* foo) { foo -> someFunc(); } class Foo: public Bar { } ? Thanks! ...

Template assertion in C++?

Is there a way to define a template assertInheritsFrom<A, B> such that assertsInheritsFrom<A, B> compiles if and only if class A : public B { ... } // struct A is okay too Thanks! ...

Connecting Actionscript 3.0 with a C++ backend?

I am curious to know if there is a way of connecting a flash front-end to a C++ driven backend? I'm not currently working on a project that involves this, but I found out about an application used in the gaming industry, called Scaleform, that requires knowledge on doing such things in order to create menus in games. ...

How does c++ auto_ptr relate to managed pointers (Java, C#...)

I come from a managed world and c++ automatic memory management is quite unclear to me If I understand correctly, I encapsulate a pointer within a stack object and when auto_ptr becomes out of scope, it automatically calls delete on the pointed object? What kind of usage should I make of it and how should I naturally avoid inherent c++...

Iterating the std::list through a const_iterator

is it possible to iterate through until the end of list in main() function using the const_iterator? I tried using iter->end() but i can't figure it out. #include <list> #include <string> using std::list; using std::string; class list_return { public: list <string>::const_iterator get_list() { _list.push_back("1"); _list.push_back("2")...

C++ How to I replace this if...else statement?

I have the following C++ code (simplified version): class Shape { bool isCircle = false; bool isSquare = false; } class Circle : public Shape { // some special members/methods } class Square : public Shape { // some special members/methods } class CAD { virtual DrawCircle(Circle * circle) = 0; } class SWX : publi...

C++ code related to matrix,n*n grid etc

Hii, The problem statement is: Buttons Each cell of an N x N grid is either a 0 or a 1. You are given two such N x N grids, the initial grid and the final grid. There is a button against each row and each column of the initial N x N grid. Pressing a row-button toggles the values of all the cells in that row, and pressing a column-butto...

Indexing text content of html

I want to pull the text out of html files for indexing purposes, and do so as fast as possible. Rather than create something from scratch, I want to see how much I can find already done for me. Currently I'm just piping the output of html2text, which works, but between being python and trying to prettify the text, I'm sure the speed cou...

Unexpected Memory Leak [Valgrind]

Today I was just trying to check how valgrind works. So I created a simple program. //leak.C #include<iostream> class leak { int *p; public: leak():p(new int[10]()){std::cout<<"Constructor of leak called\n";} virtual void set() { for(int i=0;i<10;++i) p[i]=i*i; } virtual void display() { std::...

Is it possible to create an object of a class using new operator inside the namespace ?

Hi, Let me consider the following example! namespace nSpace { class Addition { int val1; int val2; public: Addition(int firstVal, int secondVal) { this.val1 = firstVal; this.val2 = secondval; } void sum() { cout<<"sum of val1 and val2 = " <<this.val1 + this.val2<<"\n"; ...

How to get address of member function for local class defined in function (C++)

I am trying to do the following: Obtain the address of a member function from a class that was locally defined within a function. class ConnectionBase { }; template class<EventType, SinkType> class ConnectionImpl : public ConnectionBase { public: typedef void (SinkType::*EventCallback)(EventType const&); }; template<class EventType> ...