AgnelCodes
BAN USERIn particular, here's when you need to make your destructor virtual:
* if someone will derive from your class,
* and if someone will say new Derived, where Derived is derived from your class,
* and if someone will say delete p, where the actual object's type is Derived but the pointer p's type is your class.
More info : www parashift com/c++-faq-lite/virtual-functions.html#faq-20.7
MacOS - Microkernel
it (dot) toolbox.com/wiki/index.php/Kinds_of_Kernels
Isn't it Global, Stack and Heap?
Global - Static, global variables,
Stack - Stack frame contains the local variables inside functions, params, automatic variables
Heap - Dynamic memory allocation
and... compiled code which is read only.
I came across this page which had a detailed explanation.
"If during stack unwinding a destructor throws an exception and that exception is not handled, the terminate() function is called."
Code taken from the public library of IBM.
#include <iostream>
using namespace std;
struct E {
const char* message;
E(const char* arg) : message(arg) { }
};
void my_terminate() {
cout << "Call to my_terminate" << endl;
};
struct A {
A() { cout << "In constructor of A" << endl; }
~A() {
cout << "In destructor of A" << endl;
throw E("Exception thrown in ~A()");
}
};
struct B {
B() { cout << "In constructor of B" << endl; }
~B() { cout << "In destructor of B" << endl; }
};
int main() {
set_terminate(my_terminate);
try {
cout << "In try block" << endl;
A a;
B b;
throw("Exception thrown in try block of main()");
}
catch (const char* e) {
cout << "Exception: " << e << endl;
}
catch (...) {
cout << "Some exception caught in main()" << endl;
}
cout << "Resume execution of main()" << endl;
}
Output :
In try block
In constructor of A
In constructor of B
In destructor of B
In destructor of A
Call to my_terminate
Throw is called in the destructor of A which isn't handled, so the program calls terminate.
This is a memory intensive operation if you read from a large file.
Instead use the built in $_ to read the file line by line and use a count variable.
EDIT:
I didn't read the solution above mine, bubble sort would solve it quicker than Selection sort.
Yes, bubble sort would solve it faster than selection sort.
- AgnelCodes July 04, 2010
Answer is incomplete. This will not return the position. The bit needs to be shifted in order to count the position.
- AgnelCodes August 03, 2010