class matrix
{
     int **p;
     int d1,d2;
public:
     matrix(int x,int y); //constructor allocates block of specified size
                     /*I am not specifying contructor code*/
    void get_element(int i,int j,int value)
    {    p[i][j]=value;   }
    int put_element(int i,int j)
    {   return p[i][j];   }  // [U][B]return statement encountering access violation during runtime , Help!!![/B][/U]
};

Please use code tags.

class matrix
{
	int **p;
	int d1,d2;
public:
	matrix(int x,int y); //constructor allocates block of specified size
	/*I am not specifying contructor code*/


	void get_element(int i,int j,int value)
	{ 
		p[i][j]=value; 
	}
	int put_element(int i,int j)
	{ 
		return p[i][j]; 
	} // return statement encountering access violation during runtime , Help!!!
};

You're going to have to post more code unless someone else sees something wrong with what you posted. I don't. I'm guessing the problem is in your constructor.

your constructor is probably wrong

int put_element(int i, int j)
{
    // check here that both i and j are within the bounds
    // you currently have allocated ...
    // And remember that indexes are zero-based, i.e.
    // if you have 'int arr[2]', the last valid index is 1 (not 2)
    return p[i][j];
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.