In C++ you can easily allocate one dimensional array like this:
T *array=new T[N];
And you can delete it with one statement too:
delete[] array;
The compiler will know the magic how to deallocate the correct number of bytes.
But why can't you alloc 2-dimensional arrays like this?
T *array=new T[N,M];
Or even like this?
T *arra...
I want to embed(make OneNote a control) in my application. I know Excel is possible using a control in .Net but I don't know how to make OneNote embedded. The languages I can use are C++ or C#.
...
I have come unstuck on a relatively (almost) trivial problem. I have a row of data that I want to display in tabular form (HTML). For some reason (possibly long day [again] behind the computer), I am not coming up with any elegant solutions (algorithms) to do this.
I have presented some sample data, and how such data would be displayed ...
Hi
I have path to a folder for example
/myfolder
or in Windows:
C:\myfolder
and I want to get a list of all files in that folder. How shall I do so in C?
Is it different in C++ or C99?
How can I get a list of its folders?
Any help is appreciated.
...
i have following program to calculate size of file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string line;
ifstream myfile ("C:\\Users\\7\\Desktop\\example\\text.txt",ios::in | ios::out |ios::binary);
if (!myfile){
cout<<"cannot open file";
exit (1);
}
...
Hi,
I'm looking for a simple example for camera access in Linux using V4L2.
Where I can find it? As simple, as possible.
Thanks,
...
How is STL vector usually implemented? It has a raw storage of char[] which it occasionally resizes by a certain factor and then calls placement new when an element is pushed_back (a very interesting grammatical form I should note - linguists should study such verb forms as pushed_back :)
And then there are the alignment requirements. S...
CompVision once again, im working with jpeg images in my application. Just because i'm a bit familiar with MFC and ATL, i used CImage to access pixel values.
For my needs i calculate brightness matrix for the image during initialization. Function goes like this(Image is the name of my own class, unimportant, bright is float[][]):
voi...
I'm trying to get the following code to work, but I can't find good-enough documentation on how C++ handles public vs. private inheritance to allow me to do what I want. If someone could explain why I can't access Parent::setSize(int) or Parent::size using private inheritance or Parent::size using public inheritance. To solve this, to ...
I have the following code (I'm sorry for the lengthiness):
double primeValue( const func1D &func,
const double lowerBound, const double upperBound,
const double pole )
{
// check bounds
if( lowerBound >= upperBound )
throw runtime_error( "lowerBound must be smaller than upperBound!" ...
I have the following declaration in a file that gets generated by a perl script ( during compilation ):
struct _gamedata
{
short res_count;
struct
{
void * resptr;
short id;
short type;
} res_table[3];
}
_gamecoderes =
{
3,
{
{ &char_resource_ID_RES_welcome_object_ID,1002, 1001 },
{ &blah_resource_ID_RES_another_object...
I have written a simple single threaded client server application in Visual C++. When I run my server I wait for some time that it accepts some request from the client.
When I connect the client to the server. The log message on the client reports 14 bytes are send and there is no message on the server. I have written a print statement ...
I have following code to accomplish prefix sum task:
#include <iostream>
#include<math.h>
using namespace std;
int Log(int n){
int count=1;
while (n!=0){
n>>=1;
count++;
}
return count;
}
int main(){
int x[16]={39,21,20,50,13,18,2,33,49,39,47,15,30,47,24,1};
int n=size...
Hello, I can't understand one problem:
Types.hpp:
enum SomeEnum { one, two, three };
First.hpp:
#include "Types.hpp"
class First
{
public: void someFunc(SomeEnum type) { /* ... */ }
};
Second.hpp:
#include "Types.hpp"
#include "First.hpp"
class Second
{
public: void Foo()
{
First obj;
obj.someFunc(two); // tw...
In an embedded (Windows CE) C++ project, I have to resample an arbitrary sample-rate down (or up) to 44100 Hz.
Is there a free and portable C/C++ library for audio resampling?
...
I've only been working with Boost.Spirit (from Boost 1.44) for three days, trying to parse raw e-mail messages by way of the exact grammar in RFC2822. I thought I was starting to understand it and get somewhere, but then I ran into a problem:
#include <iostream>
#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;
u...
What are the key steps and tools it takes to creating a 3d video game.
For example, I understand that a 3d artist will create 3d models in 3d Studio Max, or Maya, but where do these models go from there?
Are the 3d models first animated by a 3d animator in 3d Studio Max/Maya?
Then do these models along with the animation loops get sen...
Hi!
I'd like to know which one is more suitable for programming contests, online judges.
I don't want answers like "go with java" or "c++ is the fastest". I'd like to know that in more details, lets say like "95% of the time you wont need to write in c++, java solution will get accepted too" or "java has BigInteger object and c++ doesn...
I've seen two recent answers using _1 as a pure C++0x solution (no explicit mention of boost lambdas).
Is there such an animal as std::_1 I would think that having native lambdas will make such a construct redundant.
A Google code search for std::_1 brings two results from the same project so that's inconclusive.
...
that's the code:
static inline void
shrinkData(const vector<Data> &data, unsigned short shrinkType){
#define CASE_N(N) \
case(N): \
ptr = MemoryManager::requestMemory(n*sizeof(ShrinkData<N>)); \
for(int i=0; i<n; i++){ \
new(ptr) ShrinkData<N>(data[i]); \
ptr+=sizeof(ShrinkData<N>); \
...