c++

How can I send an std::vector<std::string> over a UNIX socket?

For my application, I need to be able to send an std::vector<std::string> over a UNIX socket(local), and get a copy of the vector on the other end of the socket. What's the easiest way to do this with O(1) messages relative to the size of the vector(i.e. without sending a message for each string in the vector)? Since this is all on the ...

learning C++ from Java , trying to make a linked list.

I just started learning C++ (coming from Java) and am having some serious problems with doing anything :P Currently, i am attempting to make a linked list, but must be doing something stupid cause i keep getting "void value not ignored as it ought to be" compile errors (i have it marked where it is throwing it bellow). If anyone could he...

How can I CURL POST a file using file pointer in C++

I have a file pointer, such as the following: FILE* f = tmpfile() How do I use libcurl to do a HTTP POST to a URL as a field named F1? I tried reading the file contents into a char* array but and used the following to upload: #include <stdio.h> #include <string.h> #include <stdlib.h> #include <curl/curl.h> #include <curl/types.h> #...

C++ catch constructor exception

hi. I do not seem to understand how to catch constructor exception. Here is relevant code: struct Thread { rysq::cuda::Fock fock_; template<class iterator> Thread(const rysq::cuda::Centers &centers, const iterator (&blocks)[4]) : fock_() { ...

C++ Map of Vector of Structs?

So here's a snippet of my code: struct dv_nexthop_cost_pair { unsigned short nexthop; unsigned int cost; }; map<unsigned short, vector<struct dv_nexthop_cost_pair> > dv; I'm getting the following compiler error: error: ISO C++ forbids declaration of `map' with no type What's the proper way to declare thi...

Qt/C++ or C#, which learn first??

I already know C++ console programming. So shall i learn Qt for c++ or c# first?? I eventually plan to learn both anyways. Also, how long will each one take. The only programming language i know is c++. ...

Null pointer to struct which has zero size (empty)... It is a good practice?

Hi2All.. I have some null struct, for example: struct null_type { null_type& someNonVirtualMethod() { return *this; } }; And in some function i need to pass reference to this type. Reason: template <typename T1 = null_type, typename T2 = null_type, ... > class LooksLikeATupleButItsNotATuple { public: LooksLik...

What is the biggest numerical primitive datatype in C++ (old/new standard)

Hello, I am a bit confused about old/new so that's my question. What is the biggest numerical primitive datatype in the old and in the new C++ standard? (integer and floatingpoint) regards & many thanks in advance Oops ...

extraneous calls to copy-constructor and destructor

[a follow up to this question] class A { public: A() {cout<<"A Construction" <<endl;} A(A const& a){cout<<"A Copy Construction"<<endl;} ~A() {cout<<"A Destruction" <<endl;} }; int main() { { vector<A> t; t.push_back(A()); t.push_back(A()); // once mo...

C++ smart pointers: sharing pointers vs. sharing data

In this insightful article, one of the Qt programmers tries to explain the different kinds of smart pointers Qt implements. In the beginning, he makes a distinction between sharing data and sharing the pointers themselves: First, let’s get one thing straight: there’s a difference between sharing pointers and sharing data. When yo...

C++ DLL-Linking UnResolved Externals

I have a rather big Core project that I'm working with, I'm attempting to adapt it to use a DLL Engine I've built, I'm getting a bunch of errors like: unresolved external symbol "private: static class When including some of the headers from the Core in the DLL, the class is exported via __declspec(dllexport) but any header with static ...

Deep copy vs Shallow Copy

Possible Duplicate: What is the difference between a deep copy and a shallow copy? What is the difference between deep and shallow copy. What type of a copy does a copy constructor do? ...

What does "|=" operation mean in C++ ?

I have the following code and I can't understand what does it mean: var1 |= var2>0 ? 1 : 2; Anyone can help me please! ...

How to protect code from crashes in this situation

int arr[ 5 ] = { 0 }; int i = 8; // out of bounds arr[ i ] = 8; I know that I can just check i like this if( i < 0 || i > 5 ) .... I also know about SEH in Visual Studio, but it looks like not working solution. __try { /* code */ } __except(GetExceptionCode() == EXCEPTION_ARRAY_BOUNDS_EXCEEDED) This is not working. As I see SEH...

Libtool versioning of a library that depends on other libraries.

Hello, I have a framework that uses Boost and CgiCC in the core application and in its interface. How should I version the library binary interface (a.k.a. libtool -version-info)? I have no problems tracking the changes in library itself when I make various changes. As it is clear for me how should I version. But... Both Boost and C...

How do I create both a .lib file and an .exe file in Visual C++?

I currently have a console project which creates an .exe file; I want it to also create a .lib file so other projects, compiled as DLLs, would be able to call functions from the original project. I know it is possible, but I couldn't find how to do that. How do I tell the linker to also link a .lib? ...

IADsUser change user attribute

i connect to ACtiveDirectory as Administratotr . hr = pUser->Put(L"pwdLastSet",svar); hr = pUser->SetInfo(); why hr = E_ACCESSDENIED ...

How to enable nullptr from C++0x in the Visual C++ 2010?

I wonder how can I enable the nullptr in the just released Visual Studio 2010. (C++ project, not managed). This is one of the new features but it is not available by default and looking inside the documentation at http://msdn.microsoft.com/en-us/library/4ex65770(VS.100).aspx it seams that it is enabled by /clr but this is managed! Is t...

Why is there ambiguity in this diamond pattern?

#include <iostream> using namespace std; class A { public: void eat(){ cout<<"A";} }; class B: public A { public: void eat(){ cout<<"B";} }; class C: public A { public: void eat(){ cout<<"C";} }; class D: public B,C { public: void eat(){ cout<<"D";} }; int main(){ A *a = new D(); a->eat(); } I am not sure this...

Warning about data loss c++/c

I am getting a benign warning about possible data loss warning C4244: 'argument' : conversion from 'const int' to 'float', possible loss of data Question I remember as if float has a larger precision than int. So how can data be lost if I convert from a smaller data type (int) to a larger data type (float)? ...