Looks like its all about function pointer.
But I think your code has little bit definition issue?
If I am right it should be like this:

[CODE]
typedef void ( set_malloc_handler)( void(f)() ) ;
//Which means set_malloc_handler is a function pointer, which takes another function pointer as argument.
[/CODE]

Here is an example below:

[CODE]

include <iostream>

typedef void ( set_malloc_handler)( void(f)() ) ;

void firstFun( void(*f)() ){
f();
}

void callme(){
std::cout << "Call me" << std::endl;
}
int main() {
set_malloc_handler myfun = firstFun; //myfun is a function poitner vairbale of type set_malloc_handler, and its value is firstFun
myfun(callme);
}

[/CODE]

Output of this function is:
Call me

[QUOTE]ps: thx mike, i didn't know auto could be used this way, i thought that keyword is useless [/QUOTE]
That is [URL="

[QUOTE]Barring an off-by-one error in your array indexing, it works fine on my end.[/QUOTE]
Narue is correct. It works fine at my side as well.

Try for sit D and row 8, it is somewhere in the middle. at least you should see X
Then fix your array indexing.

Hi,

Your entire program is almost correct.

Only problem is you are resetting your cinemas in display function:
[CODE]
// This is in your display function. so just before display its resetting your entire array.
for( int row = 0; row < 17; ++row )
for( int column = 0; column < 20; ++column )
{
cinema[row][column] = '*';
}
[/CODE]

Remove that code and take it to the main, you need to set cinemas to "*" only once.

so your main should look like this:

[CODE]
int main ()
{

char choice;
bool done = false;
char cinemas[17][20];

for( int row = 0; row < 17; ++row )
    for( int column = 0; column < 20; ++column )
    {
        cinemas[row][column] = '*'; //NOTICE spelling of cinemas, in your display its cinema, as that is the name of your parameter, but in main its cinemas.
    }

    //Rest of the code.

}
[/CODE]

Hi,

Here is another way of static polymorphism.
[URL="

Here is a compile time Polymorphism example for JAVA using the above classes.

EDIT: ITS SHOWING C++ CODE, BUT THESE ARE ACTUALLY JAVA CODE.

[CODE]
package com.generic.myanimal;

public interface GenericAnimal {

public void makeAnimalCry();

}
[/CODE]

[CODE]
package com.generic.myanimal;

public class Dog implements GenericAnimal {

@Override
public void makeAnimalCry() {
    // TODO Auto-generated method stub
    System.out.print("Woof Woof!!");
}

}
[/CODE]

[CODE]
package com.generic.myanimal;

public class Cat implements GenericAnimal {

@Override
public void makeAnimalCry() {
    // TODO Auto-generated method stub
    System.out.print("Miaou..");
}

}
[/CODE]

[CODE]

public class Animal <T extends GenericAnimal>{

public void makeAnimalCry(T animal){
        animal.makeAnimalCry();
}
/**
 * @param args
 */
public static void main(String[] args) {
    Dog dog = new Dog();
    Cat cat = new Cat();

    Animal<Dog> animal1 = new Animal<Dog>();
    animal1.makeAnimalCry(dog);

    Animal<Cat> animal2 = new Animal<Cat>();
    animal2.makeAnimalCry(cat);

}

}
[/CODE]

I am not expert of java, so cant give expert opinion, or I should say will give more biased opinion towards c++.

But polymorphism in C++ is way too powerful than Java. I am off to home now. Will try to write an example why C++ is more powerful.

Hi,

You need to setup your ethernet card in promiscuous mode, in linux you can use the commands to see every packet.

ifconfig eth0 promisc - Put nic into promiscuous mode to sniff traffic.
tcpdump -n host not XXX.XXX.XXX.XXX | more - Sniff net but ignore IP which is your remote session.
ifconfig eth0 -promisc - Pull nic out of promiscuous mode.

tcpdump uses [URL="

Hi,

Dont worry about subset. First try to do permutation for a word.
If you can generate permutation of a word, then subset is really easy.
You can treat each substring as a word and generate permutation for that word, you can use std::set to get rid of duplicates.

So, again, try to generate permutation for a single word!!. Do you need to help to generate permutation for a single word?

[QUOTE]No. No. No. 1) I cannot assign or copy-initialize an rvalue (since the left-hand-side does not have a identifier, it is an rvalue). 2) You cannot assign a pointer to a reference, and a pointer is not implicitly convertible to an integral type. 3) You cannot bind a non-const reference to an rvalue (which is what NULL is).
[/QUOTE]

If we say rvalue, isn't it going to change in C++0x, if we want we can hold rvalue and use move semantic. we can use like below:
[CODE]
string&& value = aFunReturningRValue();
[/CODE]

Please correct me if I am wrong.

[QUOTE]4) Via template specialization of a member-function template (if one is already available in the class).[/QUOTE]
Can you please give an example for that?

[QUOTE]You sure can but they must be initialized thus declared static[/QUOTE]
A class can also have non static constant, it has to be initialized at initialization list.

[CODE]
class A{
const int a;
public:
A(int a) : a(a){
}
};
[/CODE]

You can not do [CODE]int &var=NULL;[/CODE] and there is a reason behind it.
any & is reference and once it is initialized, it can not be initialized again, so NULL is not a varaible/memory which & refer to.
You can not even do this: [CODE]int &var=2;[/CODE]
but you can do [CODE]int *p = NULL;[/CODE], you can do this because you can reset/intialized a pointer whenever you want.

Hi,

Only way I could help now by giving some suggestions. Seeing your code I have feeling that you need to read some basic C++: reference, pointer, memory allocation.

First read a programming book/site to make sure you understand the basic memory handling using c++,
Here is a good site to start with:
[URL="

Hi,

A straight forward error is:

[CODE]
void lsmain(lua_State* L, SDL_Event event){ //Takes a SDL_Event
}
//and from main you are passing:
lsmain(L, &Event); //address of SDL_Event, this would definitely cause crash and i am kind a surprise why its not giving an compiling error!

[/CODE]

Now about the thread memory allocation, you dont need to allocate any memory for the thread as all the thread libraries take care of memory allocation.

If you want to develop any C/C++ project, first thing you need to read about memory allocation.
It will help you to avoid countless hours of debug!!!

you input and output operator takes a CGuser by reference.
Do following:

[CODE]
cout<< *user;
[/CODE]

Why I always think in hard way??!!

Anyway look at the m4ster_r0sh vector example and see how he is taking input of the number of nodes and using vector to save nodes.

After saving you can access the nodes and do whatever you like.

Why you want to declare N objects with name n1, n2, n3..nN?
It wont help you any how.

There is ways to generate name at compile time but not on runtime but still those are mainly for template programming to generate struct/class type on fly.

Can you explain why you want to do this?

anyway, if you want to give a node identifier anyway, why not change your Node class and save the node identifier

[CODE]
class Node{
int identifier;
public:
Node(int id): identifier(id){ }
}
[/CODE]

seeing at your code looks like you already have some id to identify the object.
STL containers are mainly there to hold the unnamed objects, you wouldnt get any benefit by giving names like n1, n2..nN to all the nodes. you can identify a node using the identifier anyway.

If you explain little bit more whats your goal is, then I might give you a better example.

several things have gone wrong here.
But my first suggestion is use stl::vector

See inline commands below:

[CODE]

include <iostream>
include <string>

using namespace std;

string test()
{
string a[5] = {"Hello","World","How","Are","You"};

return a; //You are trying to return a local variable, once local variable out of scope, programs frees the memory, so you are returning an invalid memory.

}

int main()
{
string b[5];

b=test(); //You can not assign an array like this.

for(int i=0;i<5;i++)
    cout << b[i] << endl;

return 0;

}
[/CODE]

Now solution of your problem is, First read about local variable and pointer/reference of local variable.

second, there is a relation between an array and a pointer, you can refer an one dimensional array by pointer.
two dimensional array can be refered as double pointer and so on..

[CODE]

include <iostream>
include <string>

using namespace std;

string *test() //Notice the pointer..
{
string a[5] = {"Hello","World","How","Are","You"};

return a;  //still you are returning an invalid memory as end of this method, this memory will be invalid.

}

int main()
{

string *b=test(); //Notice the pointer to catch the array,

for(int i=0;i<5;i++)
    cout << b[i] << endl; //This will get crash as b is pointing to an invalid memory

return 0;

}
[/CODE]

you need to read about scope of variable.

I hope it helps.

try to explicitly declare template arguments, this usually happens when template argument deduction satisfy multiple template class/functions.

[CODE]
w = pow<double,int>(e, 2pij/n) //or whatever you want to be your datatype
[/CODE]

Have a look into the pow functions:
[url]http://www.cplusplus.com/reference/std/complex/pow/[/url]

Hi,

No, it will delete only one Node with a certain value.

You can delete binary tree in so many different ways.

First try to do traversing,

Inorder, preorder, postorder.

Once you understand traversing, then you can delete whatever way you like.

simplest way to delete will be, delete root, and adjust your tree.

in the above program, from main (or from some other function) check if root is null or not, if root is not null then call your remove function with the found integer in the root.

keep calling until root is not null.

I hope it helps.

what about this one? matrix[0][-1] is also invlid memory space.
[CODE]

if (matrix[sStreet][sAvenue-1] == "") {
//codes
}
[/CODE]

you have to check all the boundary, not only -1 also for +1

And about the visited, unvisited,

You are not making unvisited after the recursion.
[CODE]
//logic of the recurstion

void RecursionMethod(city){

for(all adjacent cities)
if(path exists to city and city not visited){
visited[city] = true;
RecursionMethod(city);
visited[city] = false;
}

}
[/CODE]

Hope it helps.

Debug every step slowly and see the values of your paths and decision you are making.

BTW, this problem is better suited for BFS not DFS. but DFS should also give you the result.

Hi,

I assumes matrix has created properly from the input,
Two things i notice in the recursion:

1) You are not checking the range of the matrix, -1 can lead you to matrix[-1][0] which is an invalid memory, thats why you are getting segmentation fault.

2) You are not keeping visited and unvisited tracks.

What is your requirement again? Can you give little more info: Like what your thread wants to do?

Lets say you have a big program running and it has some data in memory. If you want to run a scheduled job on those data(in memory) then you need to write a thread, start the thread from the main(), look the above example.

But if your job is not shared (that means the data stored in some db, or file) with your main project, then you can write a stand alone program to take care of the job which can be run using cron jobs.

If you give me more info, then i might be able to give you more specific answers.

Write a simple program which will do your task.

Then use crontab to do it daily or weekly or whatever way you want.

crontab is a tool to schedule tasks.

[URL="

1st question: Linux / windows?

if you are working in Windows, I am sure there will be similar method call like pthreads.

Following examples are given using pthread.

Answer of Q 1) You can create a thread from the constructor but why do you want to create a thread from constructor, its not a good practice.

Its funny that i just replied someone with his thread question, here is the sample code which i written for him, it may be helpful for you too.

[CODE]
/*

  • thread.h
  • Created on: Nov 8, 2010
    */
ifndef THREADH
define THREADH
include <pthread.h>

class PThread{
pthread_t thread_id;

public:
PThread(){
pthread_create( &thread_id, NULL, EntryPoint, (void *)this);
}

void Start(){
    //pthread_create( &thread_id, NULL, EntryPoint, (void *)this);
}
static void *EntryPoint(void *thread){
    PThread *self = static_cast<PThread *>(thread);

    self->Run();
}
virtual void Run() = 0;  //It is a virtual method, have fun!!

};

class JobSchedular: public PThread{
virtual void Run(){
for(int i = 1; i <= 10; i++){
cout << "scheduling job" << endl;
sleep(1);
}
}
};

endif / THREADH /

[/CODE]

[CODE]
JobSchedular th1;

// th1.Start(); YOUR case constructor starts it, but not a good practice!!

[/CODE]

Answer of Q 2) Yes ofcourse

[CODE]
//look i have called Run method
self->Run();
[/CODE]

Answer of Q 3) As long as your Run method is running :) your thread will run, but if your process terminate, your thread will terminate too.

there is a method in Pthread, pthread_join which you can use/call from main, if ...

Wait a minute,

if i understand properly, do you really want to do this:
[CODE]

itk::RescaleIntensityImageFilter<itk::Image<unsigned char, 2>::Pointer ,
itk::Image<unsigned char, 2>::Pointer >::Pointer RescaleFilterType =
itk::RescaleIntensityImageFilter<itk::Image<unsigned char, 2>::Pointer ,
itk::Image<unsigned char, 2>::Pointer >::New();
[/CODE]

Because so far i understood, you are creating pointer to pointer type class and most probably that RescaleIntensityImageFilter class wont be able to Pointer to Pointer.

EDIT: OK so it is already solved!! great.

So you following code works, which is understandble because you are creating a RescaleIntensityImageFilter class of itk::Image<unsigned char, 2> type and its not POINTER.

[CODE]
itk::RescaleIntensityImageFilter<itk::Image<unsigned char, 2> ,
itk::Image<unsigned char, 2> >::Pointer RescaleFilterType =
itk::RescaleIntensityImageFilter<itk::Image
[/CODE]

So, you have to use it this way to generate class and create the object, but after creating the object you need to set those two parameter:

your class has following memeber method:

[CODE]
virtual void SetInput (const InputImageType *image)
[/CODE]

so, all i want to say, you most probably wont be able to initialize this RescaleIntensityImageFilter as a POINTER Type.

its a very easy program, simply sort the vector and then do a linear count.

[CODE]

sort(myvector.begin(), myvector.end());

iter1 = myvector.begin();

while(iter1 is not up to the end)
{
while(iter1 is not last eliment AND iter1 and iter1+1 same element)
{
iter1++;
//calculate your count. simple count++ wont work ;) you have to think of this two situate, 112 and 11112 .. notice in first sequence one two 1 and in second sequence 4 1.
}
}

[/CODE]

Think about it and let me know if you have problem of understanding it.

You dont have to delete or erase, run it in a while loop, every time you find a occurence, start searching after the found position of the sequence

here is a sample, modify it for your need:

[CODE]
int main () {
vector<int> myvector;
vector<int>::iterator it;

// set some values: myvector: 10 20 30 40 50 60 70 80 90
for (int i=1; i<10; i++) myvector.push_back(i*10);

//INSERTING TWICE TO MAKE TWO SEQUESNCE
for (int i=1; i<10; i++) myvector.push_back(i*10); myvector: 10 20 30 40 50 60 70 80 90 10 20 30 40 50 60 70 80 90

// using default comparison:
int match1[] = {40,50,60,70};
it = search (myvector.begin(), myvector.end(), match1, match1+4);

if (it!=myvector.end())
cout << "match1 found at position " << int(it-myvector.begin()) << endl;
else
cout << "match1 not found" << endl;

//NOTICE I THE FIRST PARAMETER, We ADVANCED IT TO 4 AS THERE ARE 4 INTEGER IN SEQUENCE

it = search (it+4, myvector.end(), match1, match1+4);

if (it!=myvector.end())
cout << "match1 found at position " << int(it-myvector.begin()) << endl;
else
cout << "match1 not found" << endl;

return 0;
}

[/CODE]

Do this and see what happened:

[CODE]
template <typename T> class Queue : public CharQueue <T>
[/CODE]

I develop code on Mac and Linux for unix platform, and mainly server side code, so i have very little(actually none) experience with GUI development, anyway, I use Eclipse on centos and mac. Never tried any IDE or any development on windows ;)

I also like netbean.

IMHO use netbean for java, eclipse for c++ and java. :)