I have a templated sparse_vector<T> class, and I am also using Boost UBLAS. How would I provide implicit conversions between sparse_vector<double> and boost::numeric::ublas::compressed_vector<double>?
I would also like to provide similar conversions between std::vector<double> and boost::numeric::ublas::vector<double>.
(I am using gcc...
I'm not sure what I'm missing here. This is a snippet of code that I found on a site and I placed it in my program to see how it works and then I would modify it to my liking later. I am including iostream and this code snippet is in my main function.
char buffer[80];
cout << "Enter the string: ";
cin.get(buffer, 79); // get up ...
Hello,
I'm trying to take a 2d vector of floats (input) and put them into a char* (output) in c++.
void foo(const std::vector<std::vector<float> > &input, char* &output )
{
char charBuf[sizeof(output)];
int counter = 0;
for(unsigned int i=0; i<input.size(); i++)
{
for(unsigned int p=0; p<input.at(i).size(); p++)
...
What's the problem with this code? It crashes every time.
One time it's a failed assertion "_ASSERTE(_CrtIsValidHeapPointer(pUserData));", other times it is just a "heap corrpuption" error.
Changing the buffer size affects this issue in some strange ways - sometimes it crashes on the "realloc", and other times on the "free".
I have de...
Possible Duplicate:
Unicode in C++
If I remembered correctly, the default character and string encoding in C++ are ASCII. Is there a simple way to enable Unicode support?
...
What is the preferred way to indent/un-indent text in a list within a QTextDocument?
Do I basically have to pass in the corresponding HTML tags myself?
Edit: I'm looking for a way for the user to change the indentation level of a bulleted list with the Tab key.
...
How can I access the QUndoStack of a QTextDocument?
(For example, I want to be able to add custom QUndoCommand objects to the document's undo stack)
...
cpp.cpp
extern "C"
char* GetText()
{
return "Hello, world!";
}
delphi.dpr
{$APPTYPE CONSOLE}
{$LINK 'cpp.obj'}
function _GetText: PChar; cdecl; external;
begin
WriteLn(_GetText);
end.
I can't get this to work, no matter what I try. I tried various calling conventions, playing with underscores. even creating a .c wrapper for t...
I am trying to pass a lambda expression to a function that takes a function pointer, is this even possible?
Here is some sample code, i'm using VS2010:
#include <iostream>
using namespace std;
void func(int i){cout << "I'V BEEN CALLED: " << i <<endl;}
void fptrfunc(void (*fptr)(int i), int j){fptr(j);}
int main(){
fptrfunc(func,...
I have a sample code :
#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
int firstvalue = 5, secondvalue = 15;
int * p1, * p2;
p1 = &firstvalue;
p2 = &secondvalue;
cout << "1.p1: " << p1 << ", p2: " << p2 << endl;
cout << "1.*p1: " << *p1 << ", *p2: " << *p2 << endl;
*p1 = 10;
cout << "2.p1: ...
Hi all,
I am passing some weakrefs from Python into C++ class, but C++ destructors are actively trying to access the ref when the real object is already dead, obviously it crashes...
Is there any Python C/API approach to find out if Python reference is still alive or any other known workaround for this ?
Thanks
...
I'm porting a library from char to TCHAR. the count parameter of this fragment, according to MSDN, is the number of multibyte characters, not the number of bytes. so, did I get this right? My project properties in VC9 say 'use unicode character set' and I think that's correct, but I'm not how that impacts my count parameter.
_tcsncmp(ac...
When using CM_Get_Device_ID(...) I am getting the correct value from windows 7. When using windows xp I am getting an incorrect value. For Example, on xp I get "USB\VID_2132&PID_0001\5&36FF4167&0&7" and on 7 I get "USB\VID_2132&PID_0001\413031000576". The value after the \ on PID is our serial number and it is correct on 7 but xp keeps g...
I have a small program to demonstrate simple inheritance. I am defining a Dog class which is derived from Mammal. Both classes share a simple member function called ToString(). How is Dog overriding the implementation in the Mammal class, when i'm not using the virtual keyword? (Do i even need to use the virtual keyword to override membe...
My application does a CreateIC (and later, an OpenPrinter) for the user's default printer. When this is a remote printer, and that printer is powered down or otherwise not present on the network, it takes over 20 seconds for the CreateIC to return.
I'm looking for some call I can make that will give me a quick answer if the server is...
Lets say I have 4 verticies and their texture coordinates. How could I then figure out the texture coords of a 5th vertex?
Thanks
say I have:
v1 = (0,0) tex coord(1,0)
v2....
v3...
v4...
v5 = (15,15) tex coord = ??
yea linear interpolation I suppose,
To figure out the coords I do:
vec.x / polywidth;
vec.y / polyheight;
...
Let's say I have a macro called LengthOf(array):
sizeof array / sizeof array[0]
When I make a new array of size 23, shouldn't I get 23 back for LengthOf?
WCHAR* str = new WCHAR[23];
str[22] = '\0';
size_t len = LengthOf(str); // len == 4
Why does len == 4?
UPDATE: I made a typo, it's a WCHAR*, not a WCHAR**.
...
Hey,
I would like to create simple C++ calculator using bison and flex. Please note I'm new to the creating parsers. I already found few examples in bison/flex but they were all written in C.
My goal is to create C++ code, where classes would contain nodes of values, operations, funcs - to create AST (evaluation would be done just afte...
Hello, guys! Very important question:
Please, look at my project (300Kb). I can`t use MFC/ATL, pure C++ only.
I have COM library (niapi.dll), but no sources/headers available, dll only.
There is class for connecting to server (NiApi::SrvrSession), class has login event handler (NiApi::SrvrSession::OnLogin).
I used
#import "NiApi.dll...
Is there any crossplatform C\C++ lib for files searching? (on hard drive) What I need is simple - be able to find all images on users computer in all folders and subfolders with sise >= 200kb.
How to do such thing? Can any one help me? Please.
...