-3

I am stuck on this homework question. We have to create a c++ program where class is used to store details of employee and it should have two functions 1.To add details of employee and 2.To display details of all employees. User can select which function to use in runtime. To be able to display detials of employees there should be some data hardcoded in program. I am having problem while adding details of employees to this existing hardcoded data.

#include<iostream>
#include<string>
using namespace std;

class DATA {
public:
    int ID;
string NAME, DESIGNATION, CITY;
DATA(int id, string name, string designation, string city) {
    ID = id;
    NAME = name;
    DESIGNATION = designation;
    CITY = city;
}

void add();
void showdata();
};
DATA employee[13] = {
    DATA(1, "Adam", "SrDev", "NY"),
    DATA(2, "Bob", "JrDev", "Paris"),
    DATA(3, "Charlie", "HRM", "Singapore")
};

I want to hardcode data of 3 employees and be able to add data of 10 more employees but I am getting this error.NO instance of constructor "DATA::DATA" matches the argument list Pls help..

rioV8
  • 24,506
  • 3
  • 32
  • 49

1 Answers1

0

Add a default constructor to your class: DATA() {}

Since you provided less initializers than the number of elements in the array, the remaining elements need to be default-constructed, so a default constructor is needed.

HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207