c++

Create COM DLL from Unmanaged C++ LIB

I have followed the steps here to create a COM DLL in Visual Studio 2008. My objective is to wrap an existing unmanaged C++ .lib. Is there an easy way to implement the COM interface for the lib. Or do I just have to keep adding ATL simple objects which essentially wrap the objects in my library? For example, I have added the simple AT...

Compound literals in MSVC

In GCC, I'm able to do this: (CachedPath){ino} inode->data = (struct Data)DATA_INIT; where: struct CachedPath { Ino ino; }; typedef int8_t Depth; struct Data { Offset size; Blkno root; Depth depth; }; #define DATA_INIT {0, -1, 0} MSVC gives the following error for these kind of casts: error C2143: syntax error : m...

Exception JNI (Ljava/lang/String;)Ljava/lang/String;

I have made a little program in java that accepts a string as a user input. Now i have made a dll writing its code in Visual C++. when i run my program from netbeans it displays this exception. Exception in thread "main" java.lang.UnsatisfiedLinkError: Prompt.getLine(Ljava/lang/String;)Ljava/lang/String; at Prompt.getLine(Native...

Boost serialization multiple objects

Hi all, Im trying to build a persistence module and Im thinking in serialize/deserialize the class that I need to make persistence to a file. Is possible with Boost serialization to write multiple objects into the same file? how can I read or loop through entrys in the file? Google protocol buffers could be better for me if a good perf...

Evaluation of a reference expression

As per @Potatoswatter's suggestion, I have created a new discussion. Reference is this response from @Potatoswatter Given the code snippet, int i = 3, &j = i; j = ++ i; The comment which I seek clarity on, is this. (which seems to be an important missing piece in my understanding of the unsequenced evaluation a.k.a sequence point)...

C++ error no such file or directory

Hey guys, I just started learning C++ and I have this code that I have to complete but the class header is giving me this error error: string: No such file or directory #include <vector> #include <string> class Inventory { public: Inventory (); void Update (string item, int amount); void ListByName (); void ListByQuan...

Unresolved symbol on DLL loadup.

Hi, I am loading a DLL from an application and I want the DLL to be able to use a function implemented in the application. The definition of the function is put in a header and is included in the DLL. Can anyone tell me what I am doing wrong here or whether this can't be done? Thanks for any help. App: include <API.h> extern "C" in...

Handling STL errors without exceptions

I have a project which uses STL a lot. Now I'm working on porting the project to a specific platform which doesn't support exceptions. I can disable exceptions, however I still need to handle STL errors. Is there any approach to handle STL errors correctly with exceptions disabled? Is there any third party STL implementation which helps...

Overriding xercesc::DOMElement and DOMDocument

Hi , I am wokring on migration my project from xerces 1.4 to 3.1 version. xerces :1.4 You can call the function getElementsByTagName("tagName") on DOM_Element object . Now with xerces version 3.1 getElementsByTagName requires const XMLCh* as parameter. So in order to fix this issue simple solution would be as follows: const XMLCh*...

How can I force the compiler-generated copy constructor of a class to *not* be inlined by the compiler?

Alternate question title would be: How to explicitly have the compiler generate code for the compiler-generated constructors in a specific translation unit? The problem we face is that for one code path the resulting -- thoroughly measured -- performance is better (by about 5%) if the copy-ctor calls of one object are not inlined, that ...

returning address or local variable or temporary C++ warning

Possible Duplicate: c++ warning: address of local variable Hi, When i write this code: //Returns the transpose matrix of this one SparseMatrix& SparseMatrix::transpose()const{ vector<Element> result; size_t i; for(i=0;i<_matrix.size();++i){ result.push_back(Element(_matrix.at(i)._col, _matrix.at(i)._row, _...

#include <map> statement consuming lot of time for building my project using VS 2008

One of my project is not building (after so many hours also) ... Its not proceeding further ... The psuedocode is like this: While building my project with Visual Studio 2008: #pragma message("This is going to Include map.h") #include <map> #pragma message("The Included operation of map.h over") For the above code snippet, the build ...

How to design a C++ API

I'm fairly new to advanced C++ program techniques such as templates, but I am developing a simple API for a project I'm working on. The function or method that you call can take a long time to complete. Essentially it's transferring a file over the network. It looks a bit like this. Client { int WriteFile(); int ReadFile(); } B...

Cython C++ and std::string

What is the best way of using C++ standard std::string from cython? The last cython distribution should make it easy anyway, but I wonder why there are wrappers for std::vector and not for std::string... ...

[C++] Is it possible to add some functionality to a class without subclassing?

Hi, In Ojective-C there is something called Categories which allow the user to add methods from outside the original .h or .m file (objective-c's version of .cpp) I wonder if there exist such functionally in C++.? I specially want implement << operator for debugging and maybe others of a class that is in a library I frequently use. (A...

how to extract words from a string in C++

Possible Duplicate: How do I tokenize a string in C++? I have a string "this is a string", and I want to iterate over all the words in this string. Is there a way in which i can easily do this without having to parse it. Thanks ...

what is a wrong in this code?

i have following code #include <iostream> #include <string> using namespace std; string replace(string s){ for (int i=0;i<s.length();i++){ if (s[i]> 'b' && s[i]<'f'){ s.erase(s[i]); } } return s; } int main(){ string s; cin>>s; cout<<replace(s)<<endl; return 0; } if i en...

How to overload operator==() for a pointer to the class?

I have a class called AString. It is pretty basic: class AString { public: AString(const char *pSetString = NULL); ~AString(); bool operator==(const AString &pSetString); ... protected: char *pData; int iDataSize; } Now I want to write code like this: AString *myString = new AString("foo"); if (myString == ...

Class members that are objects - Pointers or not? C++

Hi, If I create a class MyClass and it has some private member say MyOtherClass, is it better to make MyOtherClass a pointer or not? What does it mean also to have it as not a pointer in terms of where it is stored in memory? Will the object be created when the class is created? I noticed that the examples in QT usually declare class ...

How to resolve a name collision between a C++ namespace and a global function?

Hi, if I define a namespace log somewhere and make it accessible in the global scope, this will clash with double log(double) from the standard cmath header. Actually, most compilers seem to go along with it -- most versions of SunCC, MSVC, GCC -- but GCC 4.1.2 doesn't. Unfortunately, there seems no way to resolve the ambiguity, as usi...