Question

#include <iostream> #include <cstdlib> using namespace std; int **dynArray(int row, int cols) { int **myPtr; int...

#include <iostream>

#include <cstdlib>

using namespace std;

int **dynArray(int row, int cols)

{

int **myPtr;

int lab[4];

myPtr = new int *[row];

for(int i = 0; i < row; i++)

myPtr[i] = new int[lab[i]];

for(int i = 0; i<row ; i++)

if(myPtr[i] == 0)

cout<<"empty";

return myPtr;

}

void getinput(int ID,int &Station,int &labnumb)

{

cout<<" Enter your ID number: "<<endl;

cin>>ID;

cout<<" Enter your station number: "<<endl;

cin>>Station;

cout<<" Enter your lab number: "<<endl;

cin>>labnumb;

return;

}

void logout(int ID,int &Station,int &labnumb)

{

cout<< "You have been logged out."<<endl;

return;

}

void login(int **dynArray,int ID,int &Station,int &labnumb)

{

dynArray[labnumb][Station] = ID;

return;

}

bool search(int **dynArry,int ID,int &row,int &cols,int lab[])

{

cout<<"Enter user ID to check: "<<endl;

cin>>ID;

bool found = false;

for(int i = 0; i < row;i++)

for(int j = 0; j < lab[i];j++)

if(ID == dynArry[i][j])

{

found = true;

row = i;

cols = j;

}

return found;

}

void Menu(int **dynArray,int ID,int &Station,int &labnumb,int lab[])

{

int choice;

cout<<"Enter 1 for login, 2 for search,3 for exit. "<<endl;

cin>>choice;

if(choice == 1)

login(dynArray,ID,Station,labnumb);

if(choice == 2)

search(dynArray,ID,Station,labnumb,lab);

if(choice == 3)

exit(0);

}

int main()

{

int lab[4];

lab[0] = 5;

lab[1] = 6;

lab[2] = 4;

lab[3] = 3;

int **labmain;

labmain = new int*[4];

for(int i = 0; i <4 ; i++)

{

*(labmain + i) = new int;

}

labmain = dynArray(4,7);

int ID,Station,labnumb;

Menu(dynArray,ID,Station,labnumb,lab);

system("PAUSE");

return 0;

}

I keep getting this error message. In function 'int main()':

78:37: error: cannot convert 'int** (*)(int, int)' to 'int**' for argument '1' to 'void Menu(int**, int, int&, int&, int*)'

Can please tell me how to fix it.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Output: sh-4.3$ g++ -std-c++11-o main *.cpp sh-4.3$ main Enter 1 for login, 2 for search,3 for exit. Enter your ID numer: Ent

Answer:

In the code dynArray() is the name of the function. In call to functions Menu(), Search(),login() you are passing dynArray() as input. This caused the error. The input to these functions should be labmain.

Modified Code:

#include <iostream>

#include <cstdlib>

using namespace std;

int **dynArray(int row, int cols,int lab[4])

{

int **myPtr;

myPtr = new int *[row];

for(int i = 0; i < row; i++)

myPtr[i] = new int[lab[i]];

for(int i = 0; i<row ; i++)

if(myPtr[i] == 0)

cout<<"empty";

return myPtr;

}

void getinput(int ID,int &Station,int &labnumb)

{

cout<<" Enter your ID number: "<<endl;

cin>>ID;

cout<<" Enter your station number: "<<endl;

cin>>Station;

cout<<" Enter your lab number: "<<endl;

cin>>labnumb;

return;

}

void logout(int ID,int &Station,int &labnumb)

{

cout<< "You have been logged out."<<endl;

return;

}

void login(int **labmain,int ID,int &Station,int &labnumb)

{

    getinput(ID,Station,labnumb);

labmain[labnumb][Station] = ID;

return;

}

bool search(int **labmain,int ID,int &row,int &cols,int lab[4])

{

cout<<"Enter user ID to check: "<<endl;

cin>>ID;

bool found = false;

for(int i = 0; i < row;i++)

for(int j = 0; j < lab[i];j++)

if(ID == labmain[i][j])

{

found = true;

row = i;

cols = j;

}

return found;

}

void Menu(int **labmain,int ID,int &Station,int &labnumb,int lab[4])

{

int choice;

cout<<"Enter 1 for login, 2 for search,3 for exit. "<<endl;

cin>>choice;

if(choice == 1)

login(labmain,ID,Station,labnumb);

if(choice == 2)

search(labmain,ID,Station,labnumb,lab);

if(choice == 3)

exit(0);

}

int main()

{

int lab[4];

lab[0] = 5;

lab[1] = 6;

lab[2] = 4;

lab[3] = 3;

int **labmain;

labmain = dynArray(4,7,lab);

int ID,Station,labnumb;

Menu(labmain,ID,Station,labnumb,lab);

system("PAUSE");

return 0;

}

Add a comment
Know the answer?
Add Answer to:
#include <iostream> #include <cstdlib> using namespace std; int **dynArray(int row, int cols) { int **myPtr; int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #include <iostream> using namespace std; bool binarySearch(int arr[], int start, int end, int target){ //your code...

    #include <iostream> using namespace std; bool binarySearch(int arr[], int start, int end, int target){ //your code here } void fill(int arr[], int count){ for(int i = 0; i < count; i++){ cout << "Enter number: "; cin >> arr[i]; } } void display(int arr[], int count){ for(int i = 0; i < count; i++){ cout << arr[i] << endl; } } int main() { cout << "How many items: "; int count; cin >> count; int * arr = new...

  • C++ #include <iostream> using namespace std; bool checkinventoryid(int id) {    return id > 0; }...

    C++ #include <iostream> using namespace std; bool checkinventoryid(int id) {    return id > 0; } bool checkinventoryprice(float price) {    return price > 0; } void endProgram() {    system("pause");    exit(0); } void errorID(string str) {    cout << "Invalid Id!!! " << str << " should be greater than 0" << endl; } void errorPrice(string str) {    cout << "Invalid Price!!!" << str << " should be greater than 0" << endl; } int inputId() {...

  • #include <iostream> using namespace std; struct node { int base; int power; }; void insert(node ptr[],int...

    #include <iostream> using namespace std; struct node { int base; int power; }; void insert(node ptr[],int basee,int powerr) { ptr[powerr].power=powerr; ptr[powerr].base=basee; } void addition(node ptr1[],int size1,node ptr2[],int size2,node ptr3[],int size3) { for(int j=0;j<=size1;j++) { ptr3[j].base=ptr3[j].base+ptr1[j].base; } for(int j=0;j<=size2;j++) { ptr3[j].base=ptr3[j].base+ptr2[j].base; } } void display(node ptr[],int size) { if(ptr[0].base!=0) cout<<ptr[0].base<<"+"; for(int i=1; i<=size; i++) { if(ptr[i].base!=0) cout<<ptr[i].base<<"x^"<<ptr[i].power<<"+"; } } int main() { bool choice1=true; bool choice2=true; int size1,size2,base1,base2,power1,power2; cout<<"enter the max power in polynominal 1"; cin>>size1; node *a= new node[size1+1]; for(int...

  • #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car {...

    #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car { private: string reportingMark; int carNumber; string kind; bool loaded; string choice; string destination; public: Car() { reportingMark = ""; carNumber = 0; kind = "Others"; loaded = 0; destination = "NONE"; } ~Car() { } void setUpCar(string &reportingMark, int &carNumber, string &kind, bool &loaded, string &destination); }; void input(string &reportingMark, int &carNumber, string &kind, bool &loaded,string choice, string &destination); void output(string &reportingMark, int &carNumber,...

  • #include <iostream> using namespace std; struct node { int base=0; int power=0; }; void insert(node ptr[],int...

    #include <iostream> using namespace std; struct node { int base=0; int power=0; }; void insert(node ptr[],int basee,int powerr) { ptr[powerr].power=powerr; ptr[powerr].base=basee; } void subtract(node ptr1[],int size1,node ptr2[],int size2,node ptr3[]) { for(int j=0;j<=size1;j++) { if(ptr1[j].base!=0) { ptr3[j].base=(ptr3[j].base)+(ptr1[j].base); ptr3[j].power=ptr2[j].power; } } for(int j=0;j<=size2;j++) { if(ptr2[j].base!=0) { ptr3[j].base=(ptr3[j].base)-(ptr2[j].base); ptr3[j].power=ptr2[j].power; } } } void addition(node ptr1[],int size1,node ptr2[],int size2,node ptr3[]) { for(int j=0;j<=size1;j++) { if(ptr1[j].base!=0) { ptr3[j].base=(ptr3[j].base)+(ptr1[j].base); ptr3[j].power=ptr2[j].power; } } for(int j=0;j<=size2;j++) { if(ptr2[j].base!=0) { ptr3[j].base=(ptr3[j].base)+(ptr2[j].base); ptr3[j].power=ptr2[j].power; } } } void display(node ptr[],int size)...

  • #include "stdafx.h" #include <iostream> using namespace std; class dateType {    private:        int dmonth;...

    #include "stdafx.h" #include <iostream> using namespace std; class dateType {    private:        int dmonth;        int dday;        int dyear;       public:       void setdate (int month, int day, int year);    int getday()const;    int getmonth()const;    int getyear()const;    int printdate()const;    bool isleapyear(int year);    dateType (int month=0, int day=0, int year=0); }; void dateType::setdate(int month, int day, int year) {    int numofdays;    if (year<=2008)    {    dyear=year;...

  • #include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int...

    #include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...

  •    moviestruct.cpp #include <iostream> #include <fstream> #include <cstdlib> #include <ostream> #include <fstream> #include <cstdlib> #include <cstring>...

       moviestruct.cpp #include <iostream> #include <fstream> #include <cstdlib> #include <ostream> #include <fstream> #include <cstdlib> #include <cstring> using namespace std; typedef struct{ int id; char title[250]; int year; char rating[6]; int totalCopies; int rentedCopies; }movie; int loadData(ifstream &infile, movie movies[]); void printAll(movie movies[], int count); void printRated(movie movies[], int count); void printTitled(movie movies[], int count); void addMovie(movie movies[],int &count); void returnMovie(movie movies[],int count); void rentMovie(movie movies[],int count); void saveToFile(movie movies[], int count, char *filename); void printMovie(movie &m); int find(movie movies[], int...

  • PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //==...

    PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() { amount = 0.0; } }; //============================================================================ // Linked-List class definition //============================================================================ /** * Define a class containing data members and methods to *...

  • #include <iostream> #include <queue> using namespace std; class Graph { public: Graph(int n); ~Graph(); void addEdge(int...

    #include <iostream> #include <queue> using namespace std; class Graph { public: Graph(int n); ~Graph(); void addEdge(int src, int tar); void BFTraversal(); void DFTraversal(); void printVertices(); void printEdges(); private: int vertexCount; int edgeCount; bool** adjMat; void BFS(int n, bool marked[]); void DFS(int n, bool marked[]); }; Graph::Graph(int n=0) { vertexCount = n; edgeCount = 0; if(n == 0) adjMat = 0; else { adjMat = new bool* [n]; for(int i=0; i < n; i++) adjMat[i] = new bool [n]; for(int i=0;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT