I'm trying to convert a wchar_t * to BSTR.
#include <iostream>
#include <atlstr.h>
using namespace std;
int main()
{
wchar_t* pwsz = L"foo";
BSTR bstr(pwsz);
cout << SysStringLen(bstr) << endl;
getchar();
}
This prints 0, which is less than what I'd hoped. What is the correct way to do this conversion?
...
Hi, I have few questions (keeping C/C++ in context)
- When I want to use namespace?
- When I want to use classes inside namespace?
- When I should use functions/routines inside namespace (not inside class)?
Thanks.
...
#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) \
static CEntityFactory<DLLClassName> mapClassName( #mapClassName );
This is a macro from the Alien Swarm mod for Half-Life 2, meant to be compiled with MSVC.
I've never seen an argument preceeded by a # in a macro before, and I'm not sure if this is a MSVC specific thing or ...
Hi guys,
I have the following piece of code which doesn't compile when I try to instance something like CommandGlobal<int> because it tries to override virtual void Execute() const =0; with a function which returns int. It gives a non-covariance error.
class CommandBase
{
public:
virtual void Execute() const =0;
};
template<class...
Hello!
I am looking for some simple and efficient parameter container that would act like a in-memory-xml file representation (or ini-file, as another sample).
I mean, basically it could store sections and sets of parameters for each section, have easy accessors like GetValue("ParameterName") and simple return value casting.
It would ...
I've got a .dll file created in VC++ 2008 that needs to be widely distributed, but also requires external resources (namely OpenSSL libraries) to operate. The dll compiles and runs perfectly well on my own system, as well as any other system with the appropriate external libraries manually installed on them, but I need for the .dll itsel...
Hey,
I ordered Programming Windows Fifth Edition a few days ago, and started working with it.
I'm starting to learn the win32 api, however, I got a question. The windows do not look modern winxp/win vista/win 7 style at all. How do I fix this?
It currently looks like this, crap font and all.
Thanks in advance!
Machiel
...
I've been attempting for the last week or so to compile any of the GCC 4 series of compilers to run in MinGW 5.1.6 / MSYS 1.0.11 (automated installers both from Sourceforge.org) which ships with GCC version 3.4.5. The end goal is to get GCC 4.5 to install, but I haven't been able to get any of the 4.x.x compilers to build.
I've narrowe...
I have a simple function that takes a char and return a string, in C it looks like;
char* get_string(char c) {
switch(c) {
case 'A': return "some string";
Case 'B': return "some other string";
...
And it works fine, but then I wanted my code to work in C++, and the C++ compilers throws a gazillions "deprecated conversion fr...
Given the following path:
How could these smooth curves be generated given that the user provides the points and that cubic bezier is used? How would the control points or bezier handles be solved for, or how could I compute these points using cubic bezier given the user points above (the red squares) ? Basically I have an algorithm to...
I'm writing a dylib in C++, but when I try to link it into my application, it gives me an error on execution:
dyld: lazy symbol binding failed: Symbol not found: __ZN8Vector2DC1Ev
Referenced from: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/Singularity Test App
Expected in: /Users/noahz/Desktop/Singularity/Sing...
I have a system of 6 equations that I need to solve over and over again in a program (with many different inputs of course). I am currently using the Cramer's rule method of solving the system and it works quite well (it seems that my processor really likes add and multiply operations, it gets solutions in 1 microsecond despite the expli...
It seems there is something for apple
Open Source VoIP/SIP Objective-C Code
Is there a similar stack for WIndows that anyone HAS EXPERIENCE with and is easy to implement?
I have followed most of the leads here
http://www.voip-info.org/wiki/view/Open+Source+VOIP+Software
But they are abandoned or not a Standard windows C API.
...
Below, the result1 and result2 variable values are reporting different values depending upon whether or not
you compile the code with -g or with -O on GCC 4.2.1 and on GCC 3.2.0 (and I have not tried more recent GCC versions):
double double_identity(double in_double)
{
return in_double;
}
...
double result1 = ceil(log(32.0) / log(...
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
const int FILENAME_MAX=20;
int main() {
ifstream input;
char name[FILENAME_MAX + 1];
int value;
do {
cout << "Enter the filename (maximum of " << (FILENAME_MAX+1)
<< " characters: ";
cin >> name;
input.ope...
First of all to explain what I'm trying to do:
void Foo(int &num, bool condition);
Foo(x, x > 3);
This code basically would evaluate the bool of the condition before calling the function and then pass pure true or false. I'm looking for a way to make it pass the condition itself, so I could do something like this:
void Foo(int &num,...
Would there be a better way to do this using alogrithm functions like std::find()?
std::string s = "012X012Y012";
//After erasing the numbers from begining and end; the end result should be X012Y
size_t index = s.find_first_not_of("0123456789");
string::iterator iter_end = s.begin();
advance(iter_end, index);
s.erase(s.begin(), iter_e...
I have tried to implement doubly linked list in C++. Here is the code,
#include <iostream>
using namespace std;
//double linked list
class Link{
public:
long data;
Link *next;
public:
Link(long d) {
data=d;
}
void displaylink() {
cout<<data<<" "<<"\n";
}
};...
I am currently integrating an entity component system, as seen here, with a physics engine and a graphics engine. This was all fine until recently deciding that the physics should be running in its own thread. (Thanks Glenn Fiedler!)
As it is now I am simply locking a mutex shared by all subsystems when accessing components.
Snippet fr...
Apparently this key-oriented access-protection pattern:
class SomeKey {
friend class Foo;
SomeKey() {}
// possibly non-copyable too
};
class Bar {
public:
void protectedMethod(SomeKey); // only friends of SomeKey have access
};
... doesn't have a known name yet, thus i'd like to find a good one for it so we can refe...