[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,

Inheritance with virtual functions and virtual inheritance are two different things. After reading your initial question, I think you first need to read about normal inheritance with virtual functions.

Virtual functions are for implementing polymorphism.
If a class is derived from another class and when you create a object of the derived class, contiguous memory is allocated for the entire object: memory needed for base class + derived class.

See the following example:

[CODE]

class A{
int a;
virtual int getInt(){ return a;}
};

class B : A{
int b;
virtual int getInt(){ return b;}
};

B objectB; // size of objectB will be 16, 4 for int a from class A and 4 from int b from class B and 8 byte for virtual function.
[/CODE]

Notice only one pointer (8 byte) allocated for virtual function getInt() in vtable. Not two pointers for getInt() in A and getInt() in B.

I hope you know how virtual functions work, so i am not giving any example of how to use getInt(), but if you dont know, let me know.
for further reading, see below:
[URL="http://www.cplusplus.com/doc/tutorial/polymorphism/"]http://www.cplusplus.com/doc/tutorial/polymorphism/[/URL]

Virtual inheritance is used to answer the problem of memory of multiple inheritance.
Notice following code:
[CODE]
class A{
int a[1000];
};

class B : public A{
int b;
};

class C: public A{
int c;
};

class Final: public B, C{

};

//What will be the size of Final? there is common A through B and C, so how it will be treated? ...

mike_2000_17 commented: pretty good! +14

Hi,

I was thinking of writing this post as a reply of [URL="http://www.daniweb.com/software-development/cpp/threads/375854"]Need small example for compile time polymorphism and runtime polymorphism in c++.[/URL]

But later decided to open this new thread as some expert may want to give some expert opinion on this.

On the above mentioned thread, mike_2000_17 has given some example of c++ static/dynamic polymorphism. I have gave an example of java static polymorphism.

Here is another way to write static polymorphism in C++ using [URL="http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern"]CRTP[/URL] Idiom.

I have used same classes in this post what we have used in the above thread.

[CODE]

template
class Animal{

public:
void makeCry(){
T &self = static_cast<T >(this); //CRTP
self.doCry();
}
};

class Dog : public Animal{
public:
void doCry() {
std::cout << "Woof Woof!" << std::endl;
};
};

class Cat : public Animal{
public:
void doCry() {
std::cout << "Miaou.." << std::endl;
};
};

template
void makeCry(T &animal){
animal.makeCry();
}

int main() {

Dog dog;
Cat cat;
makeCry(dog);
makeCry(cat);

return 0;

}
[/CODE]

Main benefit of this is:
1) No virtual function, so no vtable. Base class does not need to add any virtual functions. It can help you to add more functionality without changing base class header.
2) static_cast happend on compile time, so minimal runtime overhead.

That is one use case of CRTP Idioms.
Here is another interesting one. Implement one operator in derived class, for example <, and you can have all other operator from Base class.

[CODE]

template
class ...

mike_2000_17 commented: Nice! I rarely use CRTP, might do so in the future! +14
m4ster_r0shi commented: Cool. Now, I'd like to see an example with the parametric base class pattern (PBCP). (CRTP is also known as the parametric subclass pattern (PSCP)) +7

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="http://www.tcpdump.org/pcap.html"]libpcap[/URL] to listen every packet. Download the library and tcpdump codes.

Opensource is the best thing ever happened to programmers.

Mike_2000_17 and Narue
Just a thought:
You should write a beginner's tutorial on C++0x for Daniweb. That will be a great way to promote this site. I can also contribute on some easier topics!!.

sergent commented: good idea! +4

Hi,

Can you please check sizeof(real) and sizeof(double) is same or not, may be lame check but only invalid memory access is the reason that making your first matrix corrupted.

On a first glance, code looks so far fine, only potential invalid memory access in the above code is while giving output, so lets check the size of those two.

Second is, can you use valgrind to see where the invalid memory access is happening, valgrind should point you exactly where you are accessing the invalid memory.

it comes free with most linux distro.

Another thing I want to point out is: Why you are allocating memory in the intializatin list, its very dangerous and could produce potential memory leak which is very hard to debug, consider the following code:

[CODE]
class A{
AnotherObject a, b;
public:
A(): a(new AnotherObject()), b(new AnotherObject()){ //What will happen if initialization of a is successful but b fails, potential memory leak.
}
}
[/CODE]

Solution of this is smart pointers. if you store value in smart pointer, lets say you you store a in the smart pointer, even b fails, smart pointer will take care of memory deallocation of a.

Last but not least, I would suggest not to define any Exception specification except throw(), it doesn't do any good.

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 myvector;
vector::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]

miss typed:

if(WIFEXISTED)
will be
if( WIFEXISTED(stat_val) )