gdb is in the gnu package, if you can run g++, then you will be able to run gdb.
gdb is most effective when it is debugging a program that has debugging symbols linked in to it. With g++, this is accomplished using the -g command line argument. For even more information, the -ggdb switch can be used which includes debugging symbols which are specific to gdb. The makefile for this tutorial uses the -ggdb switch.
Archive for July, 2010
#include
using namespace std;
const int MAX = 6;
class Array
{
private:
int a[MAX];
public:
int insert();
int del(int pos);
int reverse();
int display();
//int search(int num);
};
int Array :: insert()
{
cout << "Enter the elements\n";
for(int i=0; i> a[i];
return 0;
}
int Array::display()
{
cout <<"Your Array is\n";
for(int i=0;i<MAX;i++)
cout << a[i]<<"\t";
cout<MAX)
{
cout<<"Invalid element to delete"<<endl;
return -1;
}
/* Deleting an array element requries shifting shift the elements to the left*/
for(; i<MAX; i++)
a[i-1]=a[i];
/* a[i-1] is the current element to be deleted */
a[i-1]=0;
cout<<"After deletion"<<endl;
display();
return 0;
}
int Array::reverse()
{
for(int i=0;i<MAX/2;i++)
{
int temp=a[i];
a[i]=a[MAX-1-i];
a[MAX-1-i]=temp;
}
cout<<"after Reverse"<<endl;
display();
}
int main()
{
Array a;
cout<<"The size of a is "<<sizeof(a)<<endl;
a.insert();
cout << "your array is as shown below:\n";
a.display();
a.del(7);
a.del(2);
a.reverse();
return 0;
}