#2
You need extra level of indirection for M in inputMatrix.

Code:

void inputMatrix(double [color=red]*[/color]**M,int& line,int& col){
cout << "Input number of lines and columns : ";
cin>>line>>col;
[color=red](*M)[/color]=new double*[line];
for (int i=0; i<line; i++) {
[color=red](*M)[/color][i]=new double[col];
}
cout << "Input your matrix :"<<endl;
for (int i=0; i<line; i++)
for (int j=0; j<col; j++) cin>>[color=red](*M)[/color][i][j];
}

And then in main

Code:

inputMatrix([color=red]&[/color]M1,line1,col1);

Or alternatively, don't use an out-style parameter for M, instead pass it back as the result.

Code:

[color=red]double **[/color]inputMatrix(int& line,int& col){
cout << "Input number of lines and columns : ";
cin>>line>>col;
[color=red]double **[/color]M=new double*[line];
for (int i=0; i<line; i++) {
M[i]=new double[col];
}
cout << "Input your matrix :"<<endl;
for (int i=0; i<line; i++)
for (int j=0; j<col; j++) cin>>M[i][j];
[color=red]return M;[/color]
}

And then in main:

Code:

[color=red]M1=[/color]inputMatrix(line1,col1);

But (assuming you're just using C++ as a better C) you should create a matrix struct that binds the pointer, col, and line together.

Code:

#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
struct matrix {
double **values;
int line;
int col;
};
matrix inputMatrix(){
matrix m;
cout << "Input number of lines and columns : ";
cin>>m.line>>m.col;
m.values =new double*[m.line];
for (int i=0; i<m.line; i++) {
m.values[i]=new double[m.col];
}
cout << "Input your matrix :"<<endl;
for (int i=0; i<m.line; i++)
for (int j=0; j<m.col; j++) cin>>m.values[i][j];
return m;
}
void outputMatrix(const matrix &m) {
for (int i=0; i<m.line; i++) {
for (int j=0; j<m.col; j++)
cout << m.values[i][j] << ' ';
cout << endl;
}
}
void killMatrix(matrix &m){
for (int i=0; i<m.line; i++) delete[] m.values[i];
delete[] m.values;
m.values = NULL;
}
int main(){
matrix M1, M2, result;
M1 = inputMatrix();
// cout<<m1.line<<" "<<m1.col<<endl;
// cout<<m1.values[0][1]<<endl;
// M2 = inputMatrix();
// cout<<m2.line<<" "<<m2.col<<endl;
// result=add2Matrix(M1,M2);
outputMatrix(M1);
killMatrix(M1);
// killMatrix(M2);
// killMatrix(result);
return 0;
}

But, surely there are ready-made, tested and optimised matrix implementations out there. For example, there's Robert Davies' Newmat C++ matrix library which can be downloaded from http://www.robertnz.net/download.html.