When implementing IUnknown::QueryInterface() in C++ there're several caveats with pointers manipulation. For example, when the class implements several interfaces (multiple inheritance) explicit upcasts are necessary:
class CMyClass : public IInterface1, public IInterface2 {
};
//inside CMyClass::QueryInterface():
if( iid == __uuidof...
What is the safest communication method between two applications on the same machine, both Java and C/C++ clients with a Java server.
Are SSL sockets safe enough or they can be broken by "man in the middle" attacks?
The main concern here is how the clients can trust the local server?
Would introducing a remote server improve the secur...
Hi,
I am writing a C++ number crunching application, where the bottleneck is a function that has to calculate for double:
template<class T> inline T sqr(const T& x){return x*x;}
and another one that calculates
Base dist2(const Point& p) const
{ return sqr(x-p.x) + sqr(y-p.y) + sqr(z-p.z); }
These operations take 80% of t...
Microsoft recommends not to use 'gethostname' on IPv6 and instead use 'getaddrinfo' or 'getnameinfo'.
http://msdn.microsoft.com/en-us/library/ms899604.aspx
But 'gethostname' doesn't seem to have any problem working on IPv6. Does anyone know any reason why 'gethostname' is not recommended on IPv6?
...
There are obviously a lot of different choices out there if you want to program for the web using Java. Does anybody have recommendations for someone who wants a free software framework for web programming? I want to work on Linux, and I would prefer to avoid .net/mono.
...
I'm currently writing an applications that embedds the python interpreter. The idea is to have the program call user specified scripts on certain events in the program. I managed this part but now I want the scripts to be able to call functions in my program.
Here's my code so far:
#include "python.h"
static PyObject* myTest(PyObject...
Hello,
There is a list of C++ XMLRPC implementations in Wikipedia:
Libiqxmlrpc
Ultra lightweight XML-RPC library for C++
XML-RPC for C and C++
XmlRpc++
XmlRpc C++ client for Windows
gSOAP toolkit for C and C++ supporting XML-RPC and more
libmaia: XML-RPC for Qt/C++
I wonder that people use which of these libraries most. Do you have e...
Hi all
I am trying to use boost::bind with a boost::function using this.
It seems a trivial example but I cannot make it work.Can you help me?
Is it because it is not allowed or am I doing something wrong?
Thanks afg
// .h
class MyClass{
publc:
void DoSomething(
const std::string& a,
const std::string& b);
vo...
I've got a shared library with some homemade functions, which I compile into my other programs, but I have to link the end program with all the libraries I have used to compile the static library. Here is an example:
I have function foo in the library which requires a function from another library libbar.so.
In my main program to use f...
For the below code, if i want to convert the for loop to in-line assembly, how would it be done?
(Pardon the weird code, i just made it up.)
1) This is for the x86, using visual studio
2) This is a "how to use in line assembly" question, not a "how to optimize this code" question
3) Any other example will be fine. I will think of some...
Hello,
I've been using std::string's == operator for years on windows and linux. Now I am compiling one of my libraries on linux, it uses == heavily. On linux the following function fails, because the == returns false even when the strings are equal (case sensitive wise equal)
const Data* DataBase::getDataByName( const std::string& na...
In eclipse, whenever I create a new C++ class, or C header file, I get the following type of structure. Say I create header file example.h, I get this:
/*Comments*/
#ifndef EXAMPLE_H_
#define EXAMPLE_H_
/* Place to put all of my definitions etc. */
#endif
I think ifndef is saying that if EXAMPLE_H_ isn't defined, define it, which may...
I know this is a strange question but the idea is simple: I prefer C# syntax rather than C++:
-Setters and getters directly inside a property
-interfaces
-foreach statement
-possibility to declare an implicit cast operator
other small things...
What I really don't know is if is possible to import a c++ dll (expecially std libraries) in...
template<typename T>
class Base
{
protected:
Base() {}
T& get() { return t; }
T t;
};
template<typename T>
class Derived : public Base<T>
{
public:
Base<T>::get; // Line A
Base<T>::t; // Line B
void foo() { t = 4; get(); }
};
int main() { return 0; }
If I comment out lin...
Hello everyone!
I am currently working on a simple Scrabble implementation for a college project.
I can't get a part of it to work, though!
Check this out:
My board.h:
http://pastebin.com/J9t8VvvB
The subroutine where the error lies:
//Following snippet contained in board.cpp
//I believe the function is self-explanatory...
//Pos i...
Hi
I'm quite sure that it is a stupid issue but it drives me crazy..
how could i print on the console a TCHAR array?
DWORD error = WSAGetLastError();
TCHAR errmsg[512];
int ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, error, 0, errmsg, 511, NULL);
i need to print errmsg...
...
I've installed MTL on my Fedora Core 12 x64 system, but when building an application I get the following error:
In file included from /usr/local/include/mtl/matrix.h:41,
from /usr/local/include/mtl/mtl.h:40,
from ltiSystem.hxx:4,
from strTools.hxx:4,
from ff.cxx:3:
/usr...
Hi,
I want to know about const internals in c and c++ . How compiler imposes constantness ?
Can some one help me please.
...
I have a doubt. Assume R and S are 2 relations with attributes A and B respectively . If I have a query
Select *
From R, S
Where R.A = S.B
Does this work like a double For Loop in say c or c++
For( i=0; i<n; i++)
For( j=0; j<n; j++)
if (i == j)
//DO some work
...
I have managed to write several interpreters including
Tokenizing
Parsing, including more complicated expressions such as ((x+y)*z)/2
Building bytecode from syntax trees
Actual bytecode execution
What I didn't manage: Implementation of dictionaries/lists/arrays.
I always got stuck with getting multiple values into one variable.
My ...