No matter what I do I cannot get this code to compile. I am using Visual Studio 2015. Please help me because I must be doing something wrong. Here is the code just get it to compile please. Please provide a screenshot of the compiled code because I keep getting responses with just code and it still has errors when I copy it into VS 2015:
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <vector>
using namespace std;
class addressbook
{
private:
std::vector<char> name;
long ph_num; //class addressType :public addressbook
std::vector<char> address;
int year;
int month;
int day;
char gender;
int d, Th, y;
char M, F, m, f;
// char freind[];
public:
addressbook();
void setName();
void getName();
void getphone();
long setphone();
void setAddress();
void getAddress();
float getAverage();
int setDay();
void getDay();
int setMonth();
void getMonth();
int setYear();
void getYear();
char setGender();
void getGender();
};
addressbook::addressbook() // constructor
{
name;
ph_num = 0;
year = 0;
month = 0;
day = 0;
}
int addressbook::setDay()
{
cout << "\n\tEnter the day:\n\t" << endl;
cin >> d;
day = (d >= 1 && d < 32) ? d : 0;
return day;
}
int addressbook::setMonth()
{
cout << "\n\tEnter the mounth:\n\t" << endl;
cin >> m;
month = (Th >= 1 && Th < 13) ? Th : 0;
return month;
}
int addressbook::setYear()
{
cout << "\n\tEnter the year :\n\t" << endl;
cin >> y;
year = (y >= 1 && y < 2008) ? y : 0;
return year;
}
void addressbook::getMonth()
{
cout << month << "/";
}
void addressbook::getDay()
{
cout << "\tBIRTH DAY : " << day << "/";
}
void addressbook::getYear()
{
cout << year;
}
char addressbook::setGender()
{
int flag = 0;
cout << " \n\tEnter the gender,(F)for female (M)for male:\n\t";
cin >> gender;
while (flag != 1)
{
if (gender == ('F') || gender == ('M') || gender == ('m') || gender == ('f'))
flag = 1;
else
{
cout << "\t error.....Try Again\n\t";
cin >> gender;
return gender;
}
}
}
void addressbook::getGender()
{
cout << "\tGender : " << gender << endl;
}
void addressbook::getAddress()
{
cout << "\tAddress : " << endl;
}
float addressbook::getAverage()
{
return 0.0f;
}
void addressbook::setAddress()
{
cout << " \n\tEnter the address:\n\t" << endl;
gets_s(address);
}
void addressbook::setName()
{
cout << " \tEnter the name:\n\t" << endl;
gets_s(name);
}
void addressbook::getName()
{
cout << "\n\tName : " << endl;
}
long addressbook::setphone()
{
cout << " \n\tEnter the person number:\n\t" << endl;
cin >> ph_num;
return ph_num;
}
void addressbook::getphone()
{
cout << "\tPerson # : " << ph_num << endl;
}
/*class addressType :public addressbook
{
do that
};*/
int main()
{
int s;
cout << " Enter number person max(500): ";
cin >> s;
vector<addressbook> book(10);
for (int i = 1; i < 2; i++)
{
book[i].setName();
book[i].setphone();
book[i].setAddress();
book[i].setDay();
book[i].setMonth();
book[i].setYear();
book[i].setGender();
cout << "\n\n ***********************************\n";
}
for (int u = 0; u < 2; u++)
{
book[u].getName();
book[u].getphone();
book[u].getAddress();
book[u].getGender();
book[u].getDay();
book[u].getMonth();
book[u].getYear();
}
_getch();
}
}
correct code:- compiled
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <vector>
using namespace std;
class addressbook
{
private:
std::vector<string> name;
long ph_num; //class addressType :public addressbook
std::vector<string> address;
int year;
int month;
int day;
char gender;
int d, Th, y;
char M, F, m, f;
string address1,name1;
// char freind[];
public:
addressbook();
void setName();
void getName();
void getphone();
long setphone();
void setAddress();
void getAddress();
float getAverage();
int setDay();
void getDay();
int setMonth();
void getMonth();
int setYear();
void getYear();
char setGender();
void getGender();
};
addressbook::addressbook() // constructor
{
name;
ph_num = 0;
year = 0;
month = 0;
day = 0;
}
int addressbook::setDay()
{
cout << "\n\tEnter the day:\n\t" << endl;
cin >> d;
day = (d >= 1 && d < 32) ? d : 0;
return day;
}
int addressbook::setMonth()
{
cout << "\n\tEnter the mounth:\n\t" << endl;
cin >> m;
month = (Th >= 1 && Th < 13) ? Th : 0;
return month;
}
int addressbook::setYear()
{
cout << "\n\tEnter the year :\n\t" << endl;
cin >> y;
year = (y >= 1 && y < 2008) ? y : 0;
return year;
}
void addressbook::getMonth()
{
cout << month << "/";
}
void addressbook::getDay()
{
cout << "\tBIRTH DAY : " << day << "/";
}
void addressbook::getYear()
{
cout << year;
}
char addressbook::setGender()
{
int flag = 0;
cout << " \n\tEnter the gender,(F)for female (M)for
male:\n\t";
cin >> gender;
while (flag != 1)
{
if (gender == ('F') || gender == ('M') || gender == ('m') || gender
== ('f'))
flag = 1;
else
{
cout << "\t error.....Try Again\n\t";
cin >> gender;
return gender;
}
}
}
void addressbook::getGender()
{
cout << "\tGender : " << gender << endl;
}
void addressbook::getAddress()
{
cout << "\tAddress : " << address1<<endl;
}
float addressbook::getAverage()
{
return 0.0f;
}
void addressbook::setAddress()
{
cout << " \n\tEnter the address:\n\t" << endl;
std::cin>>address1;
address.push_back(address1);
}
void addressbook::setName()
{
cout << " \tEnter the name:\n\t" << endl;
std::cin>>name1;
name.push_back(name1);
}
void addressbook::getName()
{
cout << "\n\tName : " << name1<<endl;
}
long addressbook::setphone()
{
cout << " \n\tEnter the person number:\n\t" <<
endl;
cin >> ph_num;
return ph_num;
}
void addressbook::getphone()
{
cout << "\tPerson # : " << ph_num << endl;
}
/*class addressType :public addressbook
{
do that
};*/
int main()
{
int s;
cout << " Enter number person max(500): ";
cin >> s;
vector<addressbook> book(10);
for (int i = 1; i < 2; i++)
{
book[i].setName();
book[i].setphone();
book[i].setAddress();
book[i].setDay();
book[i].setMonth();
book[i].setYear();
book[i].setGender();
cout << "\n\n ***********************************\n";
}
for (int u = 0; u < 2; u++)
{
book[u].getName();
book[u].getphone();
book[u].getAddress();
book[u].getGender();
book[u].getDay();
book[u].getMonth();
book[u].getYear();
}
getch();
}
Get Answers For Free
Most questions answered within 1 hours.