-
December 14th, 2010, 07:45 AM
#1
Help Me Solving This Question
hello
our doctor give as in assignment , i already try to solve it but i got some errors...
==========
Write a function named compareArrays that takes 4 parameters, two arrays of any type
(arrA[] and arrB[]) , and two integers sizeA and sizeB, being the number of elements in the two arrays respectively. The function should return boolean value which is true if the arrays are of the same size and all the corresponding elements in both arrays arrA and arrB are equal. Otherwise, it will return false. (i.e. return false if sizeA is different from sizeB or if any element of arrA is different from the corresponding element of arrB). Test the functions by writing a C++ program.
==========
PHP Code:
#include <iostream>
template <class Type>
bool compareArrays(Type *arrA, Type *arrB);
using namespace std;
template <class Type>
bool compareArrays(Type arrA,Type arrB, int sizeA, int sizeB){
bool flag=true;
// arrayA
cout<<"Enter the number of element in arrayA:";
cin>>sizeA;
arrA= new Type[sizeA];
cout<<"Enter the elements of arrayA:";
for ( int i=0; i<sizeA; i++)
cin>>arrA[i];
// arrayB
cout<<"Enter the number of element in arrayB:";
cin>>sizeB;
arrB= new Type[sizeB];
cout<<"Enter the elements of arrayB:";
for ( int j=0; j<sizeB; j++)
cin>>arrB[j];
// compareArrays checks equivalent
while(flag){
if (sizeA!=sizeB)
{ flag= false;
break;
}
else{
for (int q=0; q<sizeA; q++)
if(arrA[q]!=arrB[q]){
flag=false;
break;}
return flag;
}
}
}
int main(){
int sA, sB;
compareArrays<int>(a ,b, sA, sB);
return 0;
}
the errors
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib Assigment7
Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\user\Desktop\Assigment7\Debug\Assigment7.exe Assigment7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|