I have some code that is crashing in a large system.
However, the code essentially boils down to the following pseudo-code.
I've removed much of the detail, as I have tried to boil this down to the bare bones;
I don't think this misses anything crucial though.
// in a DLL:
#ifdef _DLL
#define DLLEXP __declspec(dllexport)
#else
#define ...
Most interested in peer-to-peer solutions - without central server. So, I imagine it like a library that brings to my application a functionality of transparent cache management with feature of remote instances synchronization. It should support cache record timeout and forcing invalidation.
UPDATE: If not completely peer-to-peer - at l...
I have read through the documentation for Winsock2 on MSDN, but I still need clarification on a few things, if anyone can help.
I planned to make something like the the setup you get when you use WSAAsyncSelect(), but using a separate thread. Can I use WSAEventSelect() to link more than one socket to a single event object?
If I used a ...
This is a memory management question about c++ code.
using namespace std;
#include <iostream>
#include <string.h>
int main()
{
string a="first";
string *b= new string;
*b=a;
a="second";
cout << *b << ", " << a;
delete b;
return 0;
}
We can deallocate the blocks of memory that stored the string that b pointed to.
I'm assuming ...
Hi everyone,
I started to learn cpp and encountered cin as a way to receive input from the keyboard.
If I understood, cin is an object and >> is an operator defined for it.
In the way it is defined, how does it "knows" to separate words from each other?
and another thing,
what is the meaning of:
while(cin)
is cin a bool type? what does ...
The void checkboard function is not working. This is a tic tac toe game. So that function checks after each move if someone has won the game or if it is a tie. After someone wins or there is a tie the board is to be reset and the game startover. I just cannot get the void checkboard function to work. Please help me solve this problem.
...
My main project class is templated class, declared with:
template<int dim, typename typ>
where dim is number of dimensions (2 or 3), and typ is floating point data type (float or double). Based on these parameters, instances of this class have their members of specific type and vectors (math) have dim number of components.
So instanc...
Ok this is a really weird problem. I wanna start off by saying that I'm not a beginner in c++ and I'm certainly not advanced. I'm somewhere in the middle. What I'm trying to do is make a C++ OOP wrapper library (dll) of the Win32 API. Here are the classes of my library. I compiled it with Mingw using the command:
g++ -shared -o bin\win3...
I have a library which is compiled in VS 2005 and I am trying to link it with one of the old VC 6 workspace, while linking I am getting following errors.
error LNK2001: unresolved external symbol _sprintf_s
error LNK2001: unresolved external symbol _strncpy_s
error LNK2001: unresolved external symbol _strcpy_s
error LNK2001: unresol...
The Following is code of a function from a unmanged dll. It takes in a function pointer as argument and simply returns value returned by the called function.
extern __declspec(dllexport) int _stdcall callDelegate(int (*pt2Func)());
extern __declspec(dllexport) int _stdcall callDelegate(int (*pt2Func)())
{
int r = pt2Func();
re...
I'm learning the use of boost smart pointers but I'm a bit confused about a few situations.
Let's say I'm implementing a state machine where each state is implemented by a single update method.
Each state could return itself or create a new state object:
struct state
{
virtual state* update() = 0; // The point: I want to return a ...
Hello,
I am working on an application with a GUI using wxWidgets. I got an object used as a "model": its data has to be used to draw the ui and the ui should modify it. Let's call this class Model.
The structure of the applications looks like this:
A wxApp-derived object, that possesses:
a wxFrame-derived object, that possesses a
wx...
I know the standard library has its warts (find me a language with a standard library that doesn't) but I've always wondered why they felt the need to stuff two seemingly unrelated pieces of code into an include named "utility." Was there once a reason for this? Did this library once contain more things that were deemed helpful or beca...
What is the proper way to implement a getter method for a lazily-initialized member variable and maintain const-correctness? That is, I would like to have my getter method be const, because after the first time it is used, it's a normal getter method. It is only the first time (when the object is first initialized) that const does not ap...
I'm currently in the process of adding the ability for users to extend the functionality of my desktop application (C++) using plugins scripted in python.
The naive method is easy enough. Embed the python static library and follow any number of the dozens of tutorials scattered around the web describing how to initialize and call python...
My understanding of object-oriented design is very limited. My main CS teacher was an old-school C programmer with little/no C++ knowledge, so I only know the basics (polymorphism, inheritance, operator overloading, etc).
Since I've been working with a peer, I've come to discover there are some useful rules to learn, and most of the ru...
Hi there!
I've a problem with using precompiled headers in wxDev-C++.
According to wxWidgets Wiki:
---> http://wiki.wxwidgets.org/Precompiled_Headers
In wxDevCpp, using MinGW and
wxWidgets, i found the matter working
this way:
Prepare a designated precompile-header file as usual like
discussed in the chapters above!
...
Is there a way to store the x and y entered by the user into a location for the array.
I have this:
if (x == 1 && y == 1)
{
board[0][0] = playerMarker;
}
I want to make it so the x and y are stored into a variable that matches the name of a spot in an array.
But I want to try and make it more like this:
...
im using WIN32_FIND_DATA to store the data findfirstfile outputs. i want the file location (C:\file) as a string but i don't know how to get it or any other data from it.
Edit: here is my code
PTSTR pszFileName;
PTSTR pszFileName2[100];
if (search_handle)
{
do
{
pszFileName = file.cFileName;
pszFileName2[loo...
Does anybody know of a method for specializing a template depending on whether a non-member method is defined? I know there are numerous ways for specializing if a member function exists, but I've never seen a non-member example. The specific problem is specializing the operator<< for shared_ptr to apply the operator<< if the operator<< ...