0
votes

Following is my code...

    #include"PointerToArray.h"
#include <iostream>
using namespace std;
void display(const int (*displayM)[10],int resultRow,int resultColumn)
{

for(int i=0;i<resultRow;i++)
{
    for(int j=0;j<resultColumn;j++)
    {
         cout<<displayM[i][j];
    }
}

}

void read()
{
 int (*matrixA)[10],(*matrixB)[10];
 int row1,col1,row2,col2;
cout<<"Enter the number of rows and colums for Matrix1";
cin>>row1>>col1;
matrixA=new int[row1][10];
cout<<"Enter elements"<<endl;
for(int i=0;i<row1;i++)
{
    for(int j=0;j<col1;j++)
    {
         cin>>matrixA[i][j];
    }
}

cout<<"Enter the number of rows and colums for Matrix2";
cin>>row2>>col2;
matrixB=new int[row2][10];
cout<<"Enter elements"<<endl;
for(int i=0;i<row2;i++)
{
    for(int j=0;j<col2;j++)
    {
         cin>>matrixB[i][j];
    }
}

display(matrixA,row1,col1);



}

I am getting error as

1:1>C:\Progs\PointerToArray\Debug\PointerToArray.exe : fatal error LNK1120: 1 unresolved externals 2:1>PointerToArray.obj : error LNK2019: unresolved external symbol "void __cdecl display(int (*)[10],int,int)" (?display@@YAXPAY09HHH@Z) referenced in function "void __cdecl read(void)" (?read@@YAXXZ)

Can any one suggest the way?

1
The code compiles fine for me using gcc 4.6.1Pietro Lorefice
I am trying microsoft vc++...its not workoinguser654761
@user654761 if you copy-paste the exact same code you posted here in a new project, excluding the first include, it does compile.Luchian Grigore

1 Answers

6
votes

The display function signature in your .c file is different from your error message in that there is no 'const' there. Can you check that in PointerToArray.h the function declaration (prototype) does not have

void display(int (*displayM)[10],int resultRow,int resultColumn)

but

void display(const int (*displayM)[10],int resultRow,int resultColumn)

instead?

If it does you can resolve it by changing either one to match.