I overloaded operator <<
template <Typename T>
UIStream& operator<<(const T);
UIStream my_stream;
my_stream << 10 << " heads";
Works but:
my_stream << endl;
Gives compilation error:
error C2678: binary '<<' : no operator found which takes a left-hand operand of type 'UIStream' (or there is no acceptable conversion)
What is ...
I have a socket server, written in C++ using boost::asio, and I'm sending data to a client.
The server sends the data out in chunks, and the client parses each chunk as it receives it. Both are pretty much single threaded right now.
What design should I use on the server to ensure that the server is just writing out the data as fast...
Hi everyone,
So I'm learning C++ at the moment and I'm trying to work things out with pointers. Could anybody explain the following scenario:
bool testFalse = false; //testFalse = false
bool *thisIsFalse = &testFalse; //value of address of thisIsFalse shows that the address contains false
bool shouldBeFalse = &thisIsFalse; //shouldBeF...
I have a proprietary application I would like to hand out to a few people for testing, except we do not want to reveal the source to them. The application is written in C++ for Linux. It links against readily available packages on the Fedora/Ubuntu repos.
Is there any way to process the source to something intermediate... then distribu...
When you get a third-party library (c, c++), open-source (LGPL say), that does not have good documentation, what is the best way to go about understanding it to be able to integrate into your application?
The library usually has some example programs and I end up walking through the code using gdb. Any other suggestions/best-practicies?...
A big reason why I use OOP is to create code that is easily reusable. For that purpose Java style interfaces are perfect. However, when dealing with C++ I really can't achieve any sort of functionality like interfaces... at least not with ease.
I know about pure virtual base classes, but what really ticks me off is that they force me in...
Hi, I'm interested in injecting DLLs into SYSTEM owned processes on my Vista machine. I'm going about this using the traditional method of VirtualAllocEx, WriteProcessMemory and CreateRemoteThread. However, because this will be operating on SYSTEM processes, I enable SeDebugPivilege on the injecting process before opening the target pro...
I am trying to compile an object file using the code below.
//--Begin test.cpp
class A;
void (A::* f_ptr) ();
void test() {
A *a;
(a->*f_ptr)();
}
//-- End test.cpp
For GNU g++ compiler, it is able to compile the object file.
$ g++ -c test.cpp
But for Sun Studio 12 on a Solaris 10 (SPARC), it outputs an error.
$ CC -c tes...
I am looking at the NetUserSetInfo method. It can take a USER_INFO_21 structure that allows me to pass in a "one-way encrypted LAN Manager 2.x-compatible password". I think this means a HMAC-MD5 hash.
The class System.Security.Cryptography.HMACMD5 can create one of these hashes, but it needs a key (or shared secret) for that class to ...
Hi all,
I am using select call to communicate with an external subsystem (protocol for the same has been provided and implemented as a Qt thread) using serial port RS232. We do not have the hardware for the external systems and thus we have developed in house simulators using .Net 2.0 and C# to mimic the behavior of the underlying subsy...
Hi,
I have a std::map that is used by multiple threads to store data. The map is declared like this:
std::map<int, Call> calls;
From each thread, I have to acquire a mutex lock, obtain a pointer or reference to the object belonging to that thread, then release the mutex lock. I can modify the object after that because each object is ...
Hello I have the following code but it isn't working as expected, can't figure out what the problem is.
Basically, I'm executing a process (a .NET process) and passing it command line arguments, it is executed successfully by CreateProcess() but CreateProcess() isn't passing the command line arguments
What am I doing wrong here??
int ...
OK, without going into the gory details I want to use a #define macro that will expand to a #include but the '#' sign is confusing the preprocessor (as it thinks I want to quote an argument.)
For example, I want to do something like this:
#define MACRO(name) #include "name##foo"
And use it thus:
MACRO(Test)
Which will expand to:
...
Is there any way to have multiline plaintext constant literals in C++, ala Perl? Maybe some parsing trick with #includeing a file? I can't think of one, but boy, that would be nice. I know it'll be in C++0x.
...
Theres some reason for this code not reach the first else?
I got it exactly the same from vairous sources. Than I did my own encapsulation. Everything goes fine. Window is created, messages are treated, events are generated to keyborad input in the client area, the gl canvas works fine (when I force it to draw).
The only problem is that...
I have no idea why this dosent work
#include <iostream>
#include <pthread.h>
using namespace std;
void *print_message(){
cout << "Threading\n";
}
int main() {
pthread_t t1;
pthread_create(&t1, NULL, &print_message, NULL);
cout << "Hello";
return 0;
}
Error: [Description, Resource, Path, Location, Type] init...
Say I have a C++ project that is split in several subprojects. The subproject all produce a DLL and different teams of developers work on each of the subproject. Now if I want to build the main project, is there a way to avoid having to build all the subprojects by myself?
In short, I'm looking for something that does the dependency man...
Hello,
I am trying to create a vector that contains pointers, each pointer points to another vector of a type Cell which I have made using a struct.
The for loop below allows me to let the user define how many elements there are in the vector of pointers. Here's my code:
vector< vector<Cell>* > vEstore(selection);
for (int t=0; t<selec...
class Base
{
public:
virtual void foo()
{}
};
class Derived: public Base
{
public:
virtual void foo()
{}
};
int main()
{
Base *pBase = NULL;
Base objBase;
Derived objDerived;
pBase = &objDerived;
pBase->foo();
/*Here Derived class foo will be called, but i want this to call
a base clas...
I'm writing a c++ shared library that is intended to be used by other library or executable. What is the best way to add a generic logging in my library? Ideally I'd like to adapt my library to logging functionality chosen by the library's user.
Suppose i have a class in my library
class A {
public:
void method(string param1, in...