c++

C++: Why don't I need to check if references are invalid/null?

Hi all, Reading http://www.cprogramming.com/tutorial/references.html, it says: In general, references should always be valid because you must always initialize a reference. This means that barring some bizarre circumstances (see below), you can be certain that using a reference is just like using a plain old non-referenc...

How to encode video from multiple cameras into one mkv stream?

How to encode multiple video + audio streams (we want streams not to be any how encoded) from cameras into one mkv so, that sound from camera A is encoded with respect to wideo from camera A, using JAVA or C or C++? (algorithm should be working on different platforms eg win lin mac) ...

Is there any lib for crossplatform Camera like devices streams parsing?

C\C++ lib for cross-platform device streams capturing (It shall find all devices in system and be able to give me their streams for encoding or filtering or any thing else). I want it to be cross-platrorm So is there any lib like this, opensource? ...

Any software to auto generate doxygen comment blocks?

Hello, i'm developing a quite big C++ software and now (better late than neve :)) i've decided to document it in the doxy standards. There are plenty of classes, methods, functions, macros and so on therefore i'm searching for a software that would scan my source tree and insert doxy comment blocks on top of every "documentable item" to ...

Is it possible to find the KNN for a node that is *IN* the KD-tree?

Hi there, Trying to create a KNN search using a KD-tree. I can form the KD-tree fine (or at least, I believe I can!). My problem is that I am searching to find the closest 2 neighbours to every point in a list of points. So, is there a method to find the K nearest neighbours to a point using a KD tree even if the point is actually IN ...

Custom "Very Long Int" Division Issue

Hey everyone, So, for a very silly project in C++, we are making our own long integer class, called VLI (Very Long Int). The way it works (they backboned it, blame them for stupidity) is this: User inputs up to 50 digits, which are input as string. String is stored in pre-made Sequence class, which stores the string in an array, in re...

How many arguments does main() have in C/C++

Hello What numbers of arguments are used for main? What variants of main definition is possible? ...

c++ templates: problem with member specialization

I am attempting to create a template "AutoClass" that create an arbitrary class with an arbitrary set of members, such as: AutoClass<int,int,double,double> a; a.set(1,1); a.set(0,2); a.set(3,99.7); std::cout << "Hello world! " << a.get(0) << " " << a.get(1) << " " << a.get(3) << std::endl; By now I have an AutoClass with a working "se...

Problem of using cin twice.

Here is the code: string str; cin>>str; cout<<"first input:"<<str<<endl; getline(cin, str); cout<<"line input:"<<str<<endl; The result is that getline never pauses for user input, therefore the second output is always empty. After spending some time on it, I realized after the first call "cin>>str", it seems '\n' is still stored in ci...

Basic C++ Speed (initialization vs adding) and comparison speed

I was curious if anyone knows which of the following executes faster (I know this seems like a weird question but I'm trying to shave as much time and resources as possible off my program.) int i=0; i+=1; or int i; i=1; and I also was curious about which comparison is faster: //given some integer i // X is some constant i < X+...

Boost::Thread or fork() : Multithreaded HTTP Proxy

I'm testing boost::thread on a system. It happens that I needed to act as a fork(), because one thread modifies the other variables, even member variables of class I do the project using fork() or is there some alternative still using boost::thread? Basically I run this program in Linux and maybe FreeBSD. It is an http proxy,accept() ...

Declaring STL Data Structures such as Vector in the .h

I am trying to declare a private Data Structure such as the Vector in my C++ header file which I want to eventually use within the method implementation of my .cpp. An example would be my header "SomeClass.h" where I have: class SomeClass { private: Vector<T> myVector; public: void AddTtoMyVector(T add); } And in my .cpp whic...

Implement the Combine function using templates

any idea on how to do it for template? thanks For example, Combine(<list containing 6,3,1,9,7>, std::plus<int>()) should calculate ((((6+3)+1)+9)+7). Combine(const Container& c, Function fn) throw (NotEnoughElements) { your code goes here } ...

Template access of symbol in unnamed namespace

We are upgrading our XL C/C++ compiler from V8.0 to V10.1 and found some code that is now giving us an error, even though it compiled under V8.0. Here's a minimal example: test.h: #include <iostream> #include <string> template <class T> void f() { std::cout << TEST << std::endl; } test.cpp: #include <string> #include "test.h" n...

Why is sizeof giving me this result?

I have this code struct Student { char name[48]; float grade; int marks[10,5]; char gender; }; Student s; Now I have to get the sizeof s so I added printf("%d",sizeof(s)); now when I hit compile the result showing is 256 and its wrong because it shoud be 253 as because the size of char name[48]; ----> 48 and float grade; ...

C/C++ RPC Tutorial for Linux

Can someone point me to a decent RPC tutorial for (or books) linux, like in this post. I tried looking around myself, I've only found tutorials that are really old. Thanks ...

Initalizing an array before initalizing a pointer to that same array

I want to initialize an array and then initialize a pointer to that array. int *pointer; pointer = new int[4] = {3,4,2,6}; delete[] pointer; pointer = new int[4] = {2,7,3,8}; delete[] pointer; How can I do this? ...

Gamma Distribution in Boost

Hello, I'm trying to use the Gamma distribution from boost::math but it looks like it isn't possible to use it with boost::variate_generator. Could someone confirm that? Or is there a way to use it. I discovered that there is a boost::gamma_distribution undocumented that could probably be used too but it only allows to choose the alpha...

Can I use C++ header files in kernel part of a CUDA code?

I want to compare two strings in a kernel function. Can I use strcomp in file? Generally, can I use C++ libraries in my CUDA code? ...

Can anyone explain what features of the C runtime in Android (via NDK) are not supported?

More specifically, does NDK have a complete STL implementation. We're looking at this for devices running 1.6 and upwards. ...