Hi all,
Im trying to create a map, where the key is an int, and the value is an array
int red[3] = {1,0,0};
int green[3] = {0,1,0};
int blue[3] = {0,0,1};
std::map<int, int[3]> colours;
colours.insert(std::pair<int,int[3]>(GLUT_LEFT_BUTTON,red)); //THIS IS LINE 24 !
colours.insert(std::pair<int,int[3]>(GLUT_MIDDLE_BUTTON,blu...
Hi,
I am looking into alternate ways to do a Matrix Multiplication. Instead of storing my matrix as a two-dimensional array, I am using a vector such as
vector<pair<pair<int,int >,int > >
to store my matrix. The pair within my pair (pair) stores my indices (i,j) and the other int stores the value for the given (i,j) pair. I thought...
The basic pseudo code looks like this:
void myFunction()
{
int size = 10;
int * MyArray;
MyArray = new int[size];
cout << size << endl;
cout << sizeof(MyArray) << endl;
}
The first cout returns 10, as expected, while the second cout returns 4.
Anyone have an explanation?
...
in java we can do this:
public class A{
public static void main(String...str){
B b = new B();
b.doSomething(this); //How I do this in c++ ? the this self reference
}
}
public class B{
public void doSomething(A a){
//Importat stuff happen here
}
}
How can I do the same but in c++, I mean t...
From what I understand: when you pass by value, the function makes a local copy of the passed argument and uses that; when the function ends, it goes out of scope. When you pass by const reference, the function uses a reference to the passed argument that can't be modified. I don't understand, however, why one would choose one over the o...
I am planning to build an inverted index searching system with cassandra as its storage backend. But I need some guidances to build a highly efficient searching daemon server. I know a web server written in Python called tornado, my questions are:
Is Python a good choice for developing such kind of apps?
Is Nginx(or Sphinx) a good exam...
Hello guys, I have a big project compiled into libProject.so-file (shared library), I made some modules (shared libraries too) which use code from all libProject. Can I set libProject as dependence for moduleProject.so file? (gcc)
...
Is there any ReSharper/StyleCop-like Visual Studio addon for C/C++?
I'm using ReSharper and StyleCop addons every day. Just recently started a new project which involves C/C++ programming. I miss some features from these addons like code formatting, hints/tips to use cleaner and better code, documentation/uniform code requirements, opti...
With the SetupAPI.DLL I execute
Function SetupDiGetClassDevs and get a pointer or handle
Then Begin a loop
Then I run
Return = Function SetupDiEnumDeviceInterfaces with SP_DEVICE_INTERFACE_DATA.cbSize = 0 to get my size of what SP_DEVICE_INTERFACE_DATA needs to be
Then I set size and execute again
SP_DEVICE_INTERFACE_DATA.cbSize = r...
Is there a way to somehow Embed a WTL destop application in ATL ActiveX (ie extension)?
What I'm trying to achieve is to create an ActiveX control with office files Viewer.
As a base I have a desktop WTL application (written some time ago) which uses OOo v3 API to display documents.
I have created an ActiveX project, linked necessar...
Is it possible to create an ISO file of an DVD in C++ using IMAPI2 ?.How ?.Can you give me sample code.I checked in internet for 4 more days.But I couldn't find a sample.Hope that help me.Thanks in advance
...
Hi, I am trying to send the below structure through
MSMQ Message
typedef struct
{
char cfiller[7];
short MsgCode;
char cfiller1[11];
short MsgLength;
char cfiller2[2];
} MESSAGECODE;
typedef struct
{
MESSAGECODE Header;
char DealerId[16];
char GroupId[16];
long Token;...
Hi,
What is the reason for the following code that does not let me to create object.
class base
{
public:
void foo()
{ cout << "base::foo()"; }
};
class derived : private base
{
public:
void foo()
{ cout << "deived::foo()"; }
};
void main()
{
base *d = new derived();
d->foo();
}
It Gi...
I need to run this line from my c++ program:
java -jar test.jar text1 text2
the java app will give a float value and give it to the c++ program.
How can I do this? I never call a java stuff before from my ms visual studio C++ file.
...
motivation: I would like to create a utility class so that instead of having to write:
if( someVal == val1 || someVal == val2 || someVal == val3 )
I could instead write:
if( is(someVal).in(val1, val2, val3) )
which is much closer to the mathematical 'a is an element of (b,c,d)' and also would save on a lot of typing when the var...
Hi guys, I have a project. I need in shared library of it to use in extensions. I don't want to make copy of this project but with shared-library settings. Are there any way to build it using *.o-files from building project? As I understand, I can write makefile for this.
...
I have a class that contains decoded video frames. I would like my decoder to use an output_iterator to write those frames to different targets. In order to support writing directly to a file, I want to overload operator << for my decoded frame class (for use with ostream_iterator). The problem is, that operator << is meant to be used fo...
I have a following Qt code:
QVBoxLayout* box = new QVBoxLayout;
label = new QLabel(); // will be set later dynamically
box->addWidget (label);
Text in label will be set later.
The problem is that when label resizes, it resizes QVBoxLayout, and it resizes other neighboring widgets.
I don't want to make a label or layout fixed width. ...
How do I default-initialize a local variable of primitive type in C++? For example if a have a typedef:
typedef unsigned char boolean;//that's Microsoft RPC runtime typedef
I'd like to change the following line:
boolean variable = 0; //initialize to some value to ensure reproduceable behavior
retrieveValue( &variable ); // do actual ...
Hello,
I have a Boost.MultiIndex big array about 10Gb. In order to reduce the reading I thought there should be a way to keep the data in the memory and another client programs will be able to read and analyse it.
What is the proper way to organize it?
The array looks like:
struct particleID
{
int ID;// real...