return 0;
}
void menu(array<Record, 10> & addressBook)
{
int choice;
cout << "1. Input information into an record." << endl;
cout << "2. Display all information in all records. " << endl;
cout << "3. Exit the program. " << endl;
cin >> choice;
switch(choice)
{
case 1:
recordInput(addressBook);
break;
case 2:
displayInfo(addressBook);
break;
case 3:
cout << "Exiting the program." << endl;
exit(0);
default:
menu(addressBook);
}
}
void recordInput(array<Record, 10> & addressBook)
{
int recordNum, telephoneNum, age;
string firstName, lastName;
for(int i = 0; i < 10; i++)
{
cout << "Enter the record number. " << endl;
cin >> recordNum;
cout << "Enter the telephone number. " << endl;
cin >> telephoneNum;
cout << "Enter the age. " << endl;
cin >> age;
cout << "Enter the first name. " << endl;
cin >> firstName;
cout << "Enter the last name. " << endl;
cin >> lastName;
addressBook[i] = (Record(recordNum, age, telephoneNum, firstName, lastName));
}
menu(addressBook);
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: Record.h
* Author: mdustin94
*
* Created on October 5, 2017, 4:09 PM
*/
#ifndef RECORD_H
#define RECORD_H
#include <string>
class Record
{
private:
int recordNum, age, telephoneNum;
std::string firstName, lastName;
public:
Record(int precordNum, int page, int ptelehponeNum, std::string pfirstName, std::string plastName);
int getRecordNum();
int getAge();
int getTelephoneNum();
std::string getFirstName();
std::string getLastName();
};
#endif /* RECORD_H */
This is the Records.cpp file
#include "Records.h"
Record::Record(int precordNum, int page, int ptelephoneNum, std::string pfirstName, std::string plastName)
{
recordNum = precordNum;
age = page;
telephoneNum = ptelephoneNum;
firstName = pfirstName;
lastName = plastName;
}
int Record::getRecordNum()
{
return recordNum;
}
int Record::getAge()
{
return age;
}
int Record::getTelephoneNum()
{
return telephoneNum;
}
std::string Record::getFirstName()
{
return firstName;
}
std::string Record::getLastName()
{
return lastName;
}
Here are the errors
main.cpp: In function 'int main()':
main.cpp:15:23: error: use of deleted function 'std::array<Record, 10ul>::array()'
array<Record, 10> addressBook;
^~~~~~~~~~~
In file included from main.cpp:7:0:
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/array:90:12: note: 'std::array<Record, 10ul>::array()' is implicitly deleted because the default definition would be ill-formed:
struct array
^~~~~
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/include/c++/array:90:12: error: no matching function for call to 'Record::Record()'
In file included from main.cpp:4:0:
Records.h:23:9: note: candidate: Record::Record(int, int, int, std::string, std::string)
Record(int precordNum, int page, int ptelehponeNum, std::string pfirstName, std::string plastName);
^~~~~~
Records.h:23:9: note: candidate expects 5 arguments, 0 provided
Records.h:17:7: note: candidate: Record::Record(const Record&)
class Record
^~~~~~
Records.h:17:7: note: candidate expects 1 argument, 0 provided
Records.h:17:7: note: candidate: Record::Record(Record&&)
Records.h:17:7: note: candidate expects 1 argument, 0 provided
make[2]: *** [nbproject/Makefile-Debug.mk:74: build/Debug/Cygwin-Windows/main.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/dusti/OneDrive/Documents/NetBeansProjects/CppApplication_4'
make[1]: *** [nbproject/Makefile-Debug.mk:60: .build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/dusti/OneDrive/Documents/NetBeansProjects/CppApplication_4'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2
main.cpp:15:23: error: use of deleted function 'std::array<Record, 10ul>::array()'
Add a constructor without arguments in your class.
When you write array<Record, 10> addressBook;
you instruct the compiler to build a std::array with 10 instances of class Record.
But class Record has got only a constructor, which asks for 5 parameters.
So, or you provide 5 parameters for everyone of the 10 instances of Record, or you provide a constructor which doesn't ask for parameters. Record() = default;
Please note: the compiler explains that very well: