c++

virtual class in abstract class

Hello :) i would like to ask, if it's posible to make something like this: i have base class (parent) A and three other classes (childs) B C D in class A, i have virtual functions, that's ok. but what if i need a virtual class ? class A { public: virtual int func1()=0; virtual int func2()=0; virtual class AB; // !!!!??? }...

c++, boost: how to fill buffer and transfer (image) file data over network ?

Hi! I'm working on an application where I need to send a "filename", "filesize" and the filedata over the network. I created a server using boost which, for now, reads in the filesize and name. I'm wondering how I can fill a buffer with the file data (if necessary) and how to transfer it to the server. This is what I've got now: #i...

map<T,T>::iterator as parameter type

I have a template class with a private map member template <typename T> class MyClass { public: MyClass(){} private: std::map<T,T> myMap; } I would like to create a private method that accepts an iterator to the map void MyFunction(std::map<T,T>::iterator &myIter){....} However, this gets a compile error: identifier 'iterat...

Can I create a predicate that will accept both functions and functors as a parameter?

I'm working on a problem in C++ that involves lots of subset and transformation operations on a large quantity of data. To that end, I've created a map function and something like list comprehensions. I've found that a bunch of the predicates I'm writing also have inverses, so I'd need to write: template <typename type_t> bool HasTenFoo...

How do you setup istream_iterator to not ignore blank lines

I'm having problems with istream_iterator reading a file because it ignores blank lines, but I need that those blank lines are included as "". How should I modify the program below to get the 5 lines in my vector? #include <sstream> #include <string> #include <iostream> #include <vector> #include <iterator> using namespace std; int ma...

template method specialisation problem

Can anyone help me with this code. I'm trying to specialise a method. At the moment it doesn't work with one specialisation (1) but I'd like to ultimately have lots of specialisations (2, 3, 4, 5 etc) class X { public: // declaration template< int FLD > void set_native( char *ptr, unsigned int length ); // specialisati...

C++ and python simultaneously. Is it doable

Hi, I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of compl...

Can one prevent Microsoft Error Reporting for a single app?

We have an unmanaged C++ application that utilizes 3rd party APIs to read CAD files. On certain corrupted CAD files, the 3rd party library crashes and brings our EXE down with it. Because of this our main application is a separate EXE and in this way it does not get affected by the crash. Howevever, we end up with annoying Microsoft Erro...

Are there any programs out there that will convert Java code to C++?

Are there any programs out there that will convert Java code to C++? ...

Alternatives to expat for stream-oriented XML parsing in C++

Are there alternatives to expat for stream-oriented XML parsing in C++? The data that I am dealing with arrives over a TCP connection and there are multiple XML documents to deal with, which means I have to reset the XML parser every time there is a new document. The parser doesn't need to be standards-compliant; I'm interested in bein...

WinINet asynchronous mode disaster

Sorry for such a long question. It's just I've spent several days trying to solve my problem, and I'm exhausted. I'm trying to use WinINet in an asynchronous mode. And I must say... this is simply insane. I really can't understand this. It does so many things, but unfortunately its asynchronous API is so much poorly designed that it jus...

What exactly does "static" mean when declaring "global" variables in C++?

This is an expansion of the scope of a previous question of mine. What exactly is "static", how is it used, and what is the purpose of using "static" when dealing with C++? Thanks. ...

Typedefs and template specialization

Consider this code: typedef int type1; typedef int type2; template <typename> struct some_trait; template <> struct some_trait<type1> { static const int something=1; }; template <> struct some_trait<type2> { static const int something=2; }; It fails because what the compiler sees is two specializations of some_trait<int>. ...

Trying to replace my boost::asio::read with boost::asio::async_read

So, the code I started with and which works (with important caveats below) int reply_length = boost::asio::read(*m_socketptr, boost::asio::buffer((char*)reply, 6)); This works, I get the header which I then decode and follow up with another read which gets me my message and then I loop back to the top and read another header. This pe...

Perl system call causes core dump but $? remains zero

I've got a Perl script (running on Xubuntu Lucid Lynx within VirtualBox) that wraps around several C/C++ binaries feeding the inputs of one into the others. One of the lines consists of generally: my $ret_code=`cat $input | c_binary`; my $ret_val= $?; For some input files the code causes a coredump, but both $ret_val and $ret_code are...

Unused template functions in shared library

Hello I have a template function in a shared library written in C++(the function is not called anywhere in the library, so it shouldn't be generated, am i wrong?) [g++, Linux] I try to use this template function in the application but compiler gives link error.I searched the function using objdump but I can not see the function in the ...

Problem with dynamic casting

This code returns me an error whenever I try to run this code. Can some one please help me. struct m { virtual int s( ) { return 1; } }; struct n : public m { int s( ) { return 2; } }; int o( ) { n* p=new m; m* q=dynamic_cast<p>; return q->s( ); } ...

Can calling WSAStartup() from several threads cause a deadlock?

I'm developing an app that has one TCP server and several UDP servers/listeners. Each server is a separate thread, same as the worker threads for established TCP connections. I'm calling WSAStartup() in each of the threads. Sometimes, calling WSAStartup() hangs (it looks like a deadlock to me). Here is the stack trace: ntdll.dll!_Ki...

Can we use a user defined class for the key in a STL map?

I need a key in the map, however, I found it should be multiple data. Can I put these data in one user defined class and put the whole class as a key in the map? Will it impact the time efficiency? What other concerns should be applied here? ...

QrCode C/C++ API For Windows

Hi, I have looked after, without luck, a free C/C++ API for Windows that can be used in a project I am about to start. There are libraries for Java and C# but the fact is there is no one for C/C++. I need an API that can be integrated in a vs project and we cannot use libraries that run in servers ( as CGI scripts or whatever ). Does any...