I need to create a function which appends a value to a vector and returns the index of the value that was just appended.
Example:
int append(std::vector<int>& numbers, int number){
int retval = numbers.size();
// what if some other thread calls push_back(number) in between these calls?
numbers.push_back(number);
return retval;
...
Is it appropriate to give the Definition of a small Function -- which is used by two projects and has up to 10 lines of code -- into a Headerfile?
It is because i can put the Headerfile into the include-Directory, which is shared by both Projects. Otherwise i have to maintain the same cpp-Files in each Project Source Directory.
What is...
Hi,
for the past four days I am trying to understand the dijkstra's algorithm. But I can't. I have a vector of points. From that I created a cost matrix. But I don't know how to make the dijkstra's algorithm. Sources are available in net, but I am not from Computer science background, So I can't understand them. I am trying to make a f...
I have a Proprietery Client-Server application written in MFC. No clients other then my client is going to communicate with the server . For safetly reason , we are using HTTP.
Until know , we used content-length to describe the client where the response body ends. Now we are having a situation where the length isn't known in advance an...
Possible Duplicate:
How to split a string?
Hi,
I have a string say "1,0,1", how can i get the substring separated by comma operator.
...
I've the below code,
template< typename T >
class T1 {
public:
T i;
protected:
T j;
private:
T k;
friend void Test();
};
The above code has a template class T1 with three members i,j and k and a friend function Test(),
I just want to know that which member/s of T1 will be available in function Test()?
Any help in t...
I have ClassA<ARG_TYPE> and ClassB<ARG_TYPE>. Now I want want to use ClassC, that has common ARG_TYPE and mentioned classes as template arguments.
ClassC<ARG_TYPE, ClassA<ARG_TYPE>, ClassB<ARG_TYPE>> is easy.
But is it possible do declare ClassC<ARG_TYPE, ClassA, ClassB> so that both A and B classes would know to use ARG_TYPE as their...
Hi gentlemen,
How do we ususaly deal with a vector whose elements are pointers to object? My specific question is the comment at the end of the code supplied below. Thanks.
class A
{
public:
virtual int play() = 0 ;
};
class B : public A
{
public:
int play() {cout << "play in B " << endl;};
};
class C : public A
{
public:
int...
I have just been given the task of updating a legacy application from 32-bit to 64-bit. While reviewing the extent of the task, I discovered the following definition immediately before the inclusion of external (eg. platform) headers:
#define POINTER_32
I cannot find what uses this definition or what effect it has, but it looks like t...
Hi,
I want to upsample an array of captured (from webcam) OpenCV images or corresponding float arrays (Pixel values don't need to be discrete integer). Unfortunately the upsampling ratio is not always integer, so I cannot figure myself how to do it with simple linear interpolation.
Is there an easier way or a library to do this?
...
Can anyone pls let me know the exact c++ code of case sensitive comparison function of string class?
...
My question is related to this question.
#include<iostream>
template< typename T >
class T1 {
public:
T i;
void display()
{
std::cout<<i<<"\n"<<j<<"\n"<<k;
}
protected:
T j;
private:
T k;
friend void Test( T1 &obj);
};
template<typename T>
void Test(T1<T> &obj)
{
T a=T();
obj.i=a;
obj.j=a;
...
My physical file structure for a project I have is something like:
Source folder
Engine
Folder1
Folder2
etc.
I have some files in 'Source', some in 'Engine', some in 'Engine/Folder1', etc.
On my project, I have gone All Configurations->Source Directories and included Source, Engine, Engine/Folder2, etc. However, I still get error...
I need two traits concerning integers.
The first one would be like std::is_integral (or boost::is_integral), but usable with user defined types (for example a class wrapping an int, say int_wrapper): true if the type behaves like an integer and whose representation is like standard integral types (e.g. sizeof(T) * CHAR_BITS == std::num...
Possible Duplicate:
or is not valid C++ : why does this code compile ?
Hello.
I've recently encountered unusual C++ code written by someone else:
bool operator != (Point p1, Point p2)
{
return p1.X != p2.X or p1.Y != p2.Y or p1.Z != p2.Z;
};
as far as I can tell, or isn't declared anywhere, even as macros.
There are a...
I wrote a simple program to load a directX .x mesh file. My loaded image is displayed like this.
But the one which the MeshViewer shows is like this.
What should be done to get the 3D look? Which call in the DirectX library should I make?
...
vector<int> ivec(4, 3);
can anyone pls explain me the above? I'm newbie & try to learn the c++.
Thanks
...
I'm using Eclipse-CDT to develop and compile projects for Linux. As host both Linux or Windows may be used.
The project is created as Makefile project with a special build command, so I changed the build-command from make to our special one and the "Build" and "Clean" commandline approbriately. The build command uses a gcc from a direct...
How can i compile the below code without changing the status of int data?
template<typename U>
void Test(U);
template< class T >
class B {
int data;
public:
friend void Test<>( T );
};
template<typename U>
void Test(U u) {
B < int> b1;
b1.data = 7;
}
int main(int argc, char *argv[])
{
char i;
Test(i);
...
I have been asked by one of my potential employers to undertake a brainbench test for Boost (position is for C++ programmer). I have never heard/seen a brainbench test for Boost. Brainbench's website also doesn't have any hint. I was wondering perhaps it is some sort of customized solution for employers.
My question, however is, what ca...