Function errors

Hey guys getting this error i have no idea how to fix it can someone please help thank you

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 // manager.h
#include <iostream>
#include <fstream>

using namespace std;
const char name_of_file[] = "assignments.txt";//name of the file
struct AssignmentStruct
{
    string courseCode;
    string courseName;
    string description;
    string dueDate;
    string first;
};

class Manager //class
{
public:
    Manager(); //constructor

    void addNewAssignment(string[], string[], string[], string[]);
    void displayAssignment();
    void removeAssignment(string[], string[], string[], string[]);


private:
    ifstream readFile;
    ofstream writeFile;
    AssignmentStruct assignments[5];

    void writeDataToFile();
    void readDataFromFile();
};




managerIMP.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <fstream>
#include "manager.h"

Manager::Manager() //constructor to initialize private variables
{
       for(int index = 0; index < 5; index++)
    {
        assignments[index].courseCode = "";
        assignments[index].courseName = "";
        assignments[index].description = "";
        assignments[index].dueDate = "";
    } //endfor loop

    readDataFromFile(); //function to read data from file
}


void Manager::addNewAssignment(string cC, string cN, string dC, string dD)
{
    for(int index = 0; index < 5; index++)
    {
         if(assignments[index].first == " ") //check for first empty space to store data
        {
            assignments[index].courseCode = cC;
            assignments[index].courseName = cN;
            assignments[index].description = dC;
            assignments[index].dueDate = dD;

            writeDataToFile(); //send data to file
            break;
        }

    }




}

void Manager::displayAssignment()
{
    cout << "\n" << assignments[index].courseCode;
    cout << "\n " << assignments[index].courseName;
    cout << "\n" << assignments[index].description;
    cout << "\n" << assignments[index].dueDate;

}

void Manager::writeDataToFile()
{
    writeFile.open("assignments.txt");
}

void Manager::removeAssignment(string cC, string cN, string dC, string dD)
{
    int number = 0;
    char option = 0;

    assignments.displayAssignment();
    cout << "\n Please select the assignment number you wish to delete starting from 1 : ";
    cin >> number;
    cout << " Are you Sure ? Select Y : ";
    cin >> option;
    if(option == 'Y') //loop
    {
        assignments[index].courseCode[number -1] = " ";
        assignments[index].courseNamenumber -1] = " ";
        assignments[index].description[number -1] = " ";
        assignments[index].dueDate[number -1] = 0;

    }
}





manager.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// HAMANAN HOOLASIE 2015100029
#include <iostream>
#include "manager.h"


using namespace std;

int main()
{
    Manager assignment;

    int option = 0;
    string cC, cN, dC, dD;

    do
    {
        cout << " \n 1. Add New Assignment ";
        cout << " \n 2. Display Assignments ";
        cout << " \n 0. Exit";
        cout << " \n Please Enter Option 1,2,0 : \n ";
        cin >> option;
        cin.get();


        switch(option)
        {
        case 1:
            cout << " Please Enter Course Code ";
            getline(cin, cC);
            cout <<  " Please enter Course Name ";
            getline(cin, cN);
            cout << "Please enter Description ";
            getline(cin, dC);
            cout << "Please enter due date ";
            getline(cin, dD);
            assignment.addNewAssignment(cC, cN, dC, dD);
            break;
        case 2:
            assignment.displayAssignment();

            break;
        case 3:
            assignment.removeAssignment(cC, cN, dC, dD);
        case 0:
            break;

        }//end switch
    }while(option != 0);






    return 0;

}

closed account (48T7M4Gy)
Perhaps you would like to tell us what error messages you are getting, or what you are getting as output that doesn't meet your expectations.
its saying something with no matching function call ? sorry im kiind of new
closed account (48T7M4Gy)
Perhaps you could copy the error message(s) and paste here?
closed account (48T7M4Gy)
void addNewAssignment(string[], string[], string[], string[]); is wrong.
FinalProjectt\manager.cpp|43|error: no matching function for call to 'Manager::removeAssignment(std::string&, std::string&, std::string&, std::string&)'|




.... what should it be???
closed account (48T7M4Gy)
Your function header must be exactly the same as the implementation. The parameters should be strings, not string arrays hence the reference to &

Fix that and then move on to all the other errors - there are lots unfortunately. Most arise because your data model is confused between single assignment object and arrays of assignments. I suggest you look at that carefully and try to tidy it up - it is not a huge job and most of your code remains.

As an example, you display an assignment but the function refers to an unknown array element called 'index'.
closed account (48T7M4Gy)
As far as the data model is concerned I would have two classes and no struct.

The two classes would be Assignment and Manager (not the best name but ...) There is nothing particularly wrong with struct Assignment but an Assignment class is better.

All the various functionalities, methods, should be allocated carefully to the relevant class so there is no confusion/overlap/misunderstanding/errors.

However, it's up to you.
Thank you so much !
Topic archived. No new replies allowed.