c++

How do I get \0 off my string from C++ when read in C#

I'm kind of stuck here. I'm developing a custom Pipleline component for Commerce Server 2009, but that has little to do with my problem. In the setup of the pipe, I give the user a windows form to enter some values for configuration. One of those values is a URL for a SharePoint site. Commerce Server uses C++ components behind all th...

instantiated from here error

hi, my compiler is torturing me with this instantiation error which I completely don't understand. i have template class listItem: template <class T> class tListItem{ public: tListItem(T t){tData=t; next=0;} tListItem *next; T data(){return tData;} private: T tData; }; if i try to initialize an object of ...

Sharing object by reference or pointer

Say I have an object of type A having Initialize() method. The method receives object B, which are kept as the object data member. B object is shared between several objects, thus A should contain the originally received B object and not its copy. class A { public: bool Initialize(B?? b); private: ...

How do you concatenate two wchar_t* together?

I have a base wchar_t* and I'm looking to append another one onto the end. How do I do it? I cannot use deprecated functions as I am treating warnings as errors. ...

What is the C++ equivalent of C# Collection<T> and how do you use it?

I have the need to store a list/collection/array of dynamically created objects of a certain base type in C++ (and I'm new to C++). In C# I'd use a generic collection, what do I use in C++? I know I can use an array: SomeBase* _anArrayOfBase = new SomeBase[max]; But I don't get anything 'for free' with this - in other words, I can't...

How can you remove the last character from a wchar_t*?

How can I delete the last character of a wchar_t* and resize accordingly? For example, having the string "test" and bringing it down to "tes" ...

To iterate or to use a counter, that is the question

Whenever someone starts using the STL and they have a vector, you usually see: vector<int> vec ; //... code ... for( vector<int>::iterator iter = vec.begin() ; iter != vec.end() ; ++iter ) { // do stuff } I just find that whole vector<int>::iterator syntax sickitating. I know you can typedef vector<int>::iterator VecI...

C++ Overloading the >> operator

I need to overload the stream extraction operator. I need to do this by allowing a user to input a string of characters at a prompt, say "iamastring", and then the operator would extract each character from the string and test whether or not it is whitespace and if it is not whitespace store it in a character array which is then passed ...

printf boost:tuple

Is there're way to pass boost::tuple to printf()? ...

Problem searching a Binary Search Tree - Array Based

I am trying to search for a word using a key value recursively. In retrieve function: Problem is the index goes from 0, 1,3,7, to 15.... it suppose to go 0,1,3,7,8 and so forth I have the insert working as expected. I have the inorder, preorders, all working. Can someone please help me figure out this problem? I have been working on this...

How to output IEEE-754 format integer as a float

I have a unsigned long integer value which represents a float using IEEE-754 format. What is the quickest way of printing it out as a float in C++? I know one way, but am wondering if there is a convenient utility in C++ that would be better. Example of the way that I know is: union { unsigned long ul; float f; } u; u.ul = 10...

How to use DLL library file in a C++ project?

I have a C++ project and a DLL library made using C#. Is it possible to add it to the C++ project and use its methods? I am using Visual Studio 2008 ...

Passing an iterator to another function

I was wondering what would be the best way to accomplish something like this... // Iterating through a list if ( foo ) { RemoveBar( it ); } void RemoveBar( std::list< Type >::iterator it ) { it = listName.erase( it ); ...// Other stuff related to cleaning up the removed iterator } I don't think pass by value will work here. Ob...

What _can_ I use as std::map keys?

Extends. I have: struct Coord { int row, col ; bool operator<( const Coord other.row other.col ; } } ; I'm trying to create a map<Coord, Node*>, where you can look up a Node* by Coord. The problem is, it has bugs. Lookups into the map<Coord, Node*> by Coord are returning the wrong ones. I'm having difficulty figuring out ...

Qt, text on a black and white screen

I'm using Qt (embedded) to make a GUI on a black and white screen. The problem is Qt renders text with shades of grey so it is unreadable on the black and white screen. Does anyone have any idea how to make the text just use 1 bit per pixel, or purely black and white? Thanks, Mark ...

The procedure entry point _ftol2 could not be located in the dynamic link library msvcrt.dll

I've recently been tinkering with a little gameproject using VC++ 2008. I'm using SDL, OpenGL, Boost and Box2D as included libraries. It works fine on my windows 7 machine, aswell as a friend's w7 machine. How ever it wont work on my second friend's XP sp3 machine, with the vc++ 2008 SP1 redist pack installed. When he starts the .exe he ...

Is it allowed to inherit from a class in the std namespace (namely std::wstring)?

The class std::wstring is missing some operations for "normal" c strings (and literals). I would like to add these missing operations in my own custom class: #include <string> class CustomWString : public std::wstring { public: CustomWString(const char*); const char* c_str(void); }; The code above c...

Origin of term "reference" as in "pass-by-reference"

Java/C# language lawyers like to say that their language passes references by value. This would mean that a "reference" is an object-pointer which is copied when calling a function. Meanwhile, in C++ (and also in a more dynamic form in Perl and PHP) a reference is an alias to some other name (or run-time value in the dynamic case). I'm...

Can more than one boost::signal be connected to 1 slot?

i know i can connect multiple slots to the same signal. but Can I do it the other way round? having 3 signals connected to the same slot? anyone ever tried this? thanks a lot! ...

C++ Creating a Weighted Graph?

Hi, How do I create a C++ weighted Graph where each vertex in the graph has a weight (some integer value)? You can download my graph project here (RapidShare): Here is the function to create a graph from graph data stored in a text file: void GraphType::createGraph() { ifstream infile; char fileName[50]; int index; in...