It says here that
The unbounded array is similar to a
std::vector in that in can grow in
size beyond any fixed bound. However
unbounded_array is aimed at optimal
performance. Therefore unbounded_array
does not model a Sequence like
std::vector does.
What does this mean?
...
I am working on a simple 2D openGL project. It contains a main actor you can control with the keyboard arrows. I got that to work okay. What I am wanting is something that can help explain how to make another actor object follow the main actor. Maybe a tutorial on openGL. The three main things I need to learn are the actor following, col...
I am developing a simple c++ program inside Microsoft Visual Studio. This program will later be convert to DLL, in order to register it to Internet Explorer.
Inside my program, I would like to do like this:
if flag=1,
toolbar_button = green;
else
toolbar button = red;
I want to create a simple button on the Internet Explorer,...
I have a very basic question on returning a reference to an element of a vector .
There is a vector vec that stores instances of class Foo. I want to access an element from this vector . ( don't want to use the vector index) . How should I code the method getFoo here?
#include<vector>
#include<stdio.h>
#include<iostream>
#include<ma...
Consider the DUPoint class, whose declaration appears below. Assume this code appears in a file named DUPoint.h:
#include <string>
class DUPoint {
public:
DUPoint (int x, int y);
int getX () const;
int getY () const;
void setX (int x);
void setY (int y);
void print();
private:
int x_;
int y_; ...
Hey guys, I have a CS exam tomorrow. Just want to get a few questions cleared up. Thanks a lot, and I really appreciate the help.
Que 1.
What are parallel vectors?
Vectors of the same length that contain data that is meant to be processed together
Vectors that are all of the same data type
Vectors that are of the same length
Any vecto...
How do I prevent a race condition WITHOUT locking or using mutexes/semaphors in C++? I'm dealing with a nested for loop in which I will be setting a value in an array:
for (int i = 0; i < m; ++i)
for (int j = 0; j < n; ++j)
for (int k = 0; k < o; ++k)
array[k] += foo(...);
More or less, I want to deal with this so that I c...
I have a C++ class, which has the following methods:
class Bar {
...
const Foo& getFoo() const;
void setFoo(const Foo&);
};
where class Foo is convertible to std::string (it has an implicit constructor from std::string and an std::string cast operator).
I define a Boost.Python wrapper class, which, among other things, defines...
I was curious to know what would happen if I assign a negative value to an unsigned variable.
The code will look somewhat like this.
unsigned int nVal = 0;
nVal = -5;
It didn't give me any compiler error. When I ran the program the nVal was assigned a strange value! Could it be that some 2's complement value gets assigned to nVal?
...
How can the below code result in a dangling pointer.
{
char *cPointer = malloc ( some constant number );
/* some code */
free ( cPointer );
cPointer = NULL;
/* some code */
}
...
I want to build my program with LSB C++ Compiler from the Linux Standard Base http://www.linuxfoundation.org/collaborate/workgroups/lsb. Program depends on the Boost library, built with gcc 4.4 version. Compilation fails. Is it possible to build the Boost library with LSB C++ Compiler? Alternatively, is it possible to build the Boost lib...
Hello Everyone, here is my problem and I'm considering to use factory method in C++, what are your opinions ?
There are a Base Class and a lot of Subclasses.
I need to transfer objects on network via TCP.
I will create objects in first side, and using this object I will create a byte array TCP message, and send it to other side.
On t...
I want to implement some sort of lookup table in C++ that will act as a cache. It is meant to emulate a piece of hardware I'm simulating.
The keys are non-integer, so I'm guessing a hash is in order. I have no intention of inventing the wheel so I intend to use std::map for this (though suggestions for alternatives are welcome).
The q...
I found, the hard way, that at least boost::program_options is dependent of the compiler configured structure member alignment.
If you build boost using default settings and link it with a project using 4 bytes alignment (/Zp4) it will fail at runtime (made a minimal test with program_options). Boost will generate an assert indicating a...
Hi guys,
I feel a little dumb asking this, but here we go...
When trying to follow the Recursion example at the following website http://www.cplusplus.com/doc/tutorial/functions2/, I ran into a road bump that has me perplexed.
I altered the code slightly just to get my head around the code in the recursion example and I pretty much h...
This is what I'm trying to do...
char input[4];
cin >> input;
cout << "Input[0]: " << input[0] << "Input[1]: " << input[1] << "Input[2]: " << input[2] << "Input[3] " << input[3]<< "Input[4] " << input[4] <<endl;
However, when I enter "P F" I get an output of this: Input[0]:P Input[1]: Input[2]:(A weird looking square with two zeros o...
Basically I have written a game plugin that will allow server admins to update their administration tools from within game rather than having to go download it and install it. The releases are updated regularly, and the beta versions are nightly builds.
I am trying to find a way to grab the links from the website, but I cannot think of ...
I working on a game but I have a problem with the initialization of the level. (feld is just field in german)
class level{
private:
feld spielfeld[10][10];
public:
/*
other stuff
*/
void init_feld();
};
void level::init_feld()
{
for(int i=0;i!=10;i++){
for(int n=0;n!=10;n++){
spielfeld[i][n] = new feld(l...
I'm trying to use code similar to clrdump to create mini dumps in my managed process.
This managed process invokes C++/CLI code which invokes some native C++ static lib code, wherein SEH exceptions may be thrown (e.g. the occasional access violation).
C# WinForms
->
C++/CLI DLL
->
Static C++ Lib
->
ACC...
I'm trying to calculate distance between 2 points.
The 2 points I stored in a vector in c++: (0,0) and (1,1).
I'm supposed to get results as
0
1.4
1.4
0
but the actual result that I got is
0
1
-1
0
I think there's something wrong with the way I use iterator in vector.
Could somebody help? I posted the code below.
typedef struct po...