Hello everyone,

I'm trying to declare a 2-dimension (A[][]) dynamic matrix but I'm having problems ...

The A's elements need to be FLOAT.

The size of lines and columns are both vectorX.size().

Could you help me please?

One of error's message is: "cannot convert `double' to `float**' in initialization"

// --------------------------------------
	// DYNAMIC DECLARATION OF MATRIX
	float **A = 0.0; // pointer for A
	A = new float *[vectorX.size()];
	for(int i=0;i<vectorX.size();i++)
		A[i]= new float [vetorX.size()];
	// END DYNAMIC DECLARATION OF MATRIX
	// --------------------------------------

	for(int i=0; i < vectorX.size();i++)
	{
		for(int j=0; j<= i;j++)
		{
			if(vectorY[i] == "NA" and vectorZ[i] == "NA")
			{
				
				
				A[i][i]= 1.53;
			}
			else if(vectorY[i] == "NA" and vectorZ[i] != "NA")
			{
				A[i][i]= 1.63;
			}
			else if(vectorY[i] != "NA" and vectorZ[i] == "NA")
			{
				
				A[i][i]= 1.73;
			}
			else if(vectorY[i] != "NA" and vectorZ[i] != "NA")
			{
				A[i][i]= 1.73 + 0.5 ;
				
			}
		}
	}

Recommended Answers

All 2 Replies

float **A = 0.0; // pointer for A

You cannot do that. The initialisation takes a double calue (0.0) and tries to assign it to a pointer (A**) that is a type mismatch.
use instead:

float **A = 0 /* or NULL, although some people frown upon using NULL*/; // pointer for A

Thanks a lot Dr. drkybelk!

Cheers!

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.