Question

No matter what I do I cannot get this code to compile. I am using Visual...

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();

}

}

Homework Answers

Answer #1

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();
}

Know the answer?
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
Similar Questions
This code it's not working, fix it for me please #include <iostream> using namespace std; class...
This code it's not working, fix it for me please #include <iostream> using namespace std; class People {    string name;    double height; public:    void setName(string name)    {        this->name = name;    }    void setHeight(double height)    {        this->height = height;    }    double getHeight() {        return height;    }    string getName()    {        return name;    } }; int main() {    const int size...
C++ Please and thank you. I will upvote Read the following problem, and answer questions. #include<iostream>...
C++ Please and thank you. I will upvote Read the following problem, and answer questions. #include<iostream> using namespace std; void shownumbers(int, int); int main() { int x, y; cout << "Enter first number : "; cin >> x; cout << "Enter second number : "; cin >> y; shownumbers(x, y); return 0; } void shownumbers(int a, int b) { bool flag; for (int i = a + 1; i <= b; i++) { flag = false; for (int j =...
I am trying to solve the following C++ problem over structures. I am having trouble with...
I am trying to solve the following C++ problem over structures. I am having trouble with the very last structure and I made a comment next to where I am confused. I included the assignment instructions and my current code. I would appreciate if anyone can help me explain what I need to do for the last structure. Thank you. Assignment Instructions Create a program that will prompt me for each of the following items: 1. Date of Birth 2....
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath>...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath> using namespace std; void divisors(int num); int main () {    char repeat;    int num;       while (repeat !='n')    {        cout << "Enter a number: ";        cin >> num;        divisors(num);        cout << "Continue? (y or n): ";        cin >> repeat;    }    return 0; } void divisors(int num) {   ...
#include<iostream> using namespase std; int main() {     int i=1;     int j=-5;     int k=80;...
#include<iostream> using namespase std; int main() {     int i=1;     int j=-5;     int k=80;     float f=2.22;     float h=-7.5;     char a='S';     char b='M';     cout<<i<<"\t"<<j<<"\t"<<k<<endl;     Cout<<f<<"\t"<<h<<endl;     cout<<a<<"\t"<<b<<endl;     return 0;     }
How do I make this code not include negative numbers in the total or average if...
How do I make this code not include negative numbers in the total or average if they are entered? (C++) For example, if you enter 4, 2, and -2, the average should not factor in the -2 and would be equal to 3. I want the code to factor in positive numbers only. ----- #include using namespace std; int main() {    int x, total = 0, count = 0;       cout << "Type in first value ";   ...
How to stop the program from exiting after display detail. When there is food detail, it...
How to stop the program from exiting after display detail. When there is food detail, it will display and exit the program. What can i do to make it not exit the program and back to main menu. #include <iostream> #include <iomanip> #include<string.h> using namespace std; struct food{ int order_id; string food_code,flavor,customer_id; string address,name; int weight,unit_price,qty,contact_number; struct food *next; };    class Foodsystem{ food *head,*temp,*temp2,*end; static int id;    public: Foodsystem(){ head=NULL;end=NULL;} void Place_Order(); void View_food_details(); void Modify_food_details(); void Delete_food_details();...
my code has several functions; delete and backward functions are not working, rewrite the code for...
my code has several functions; delete and backward functions are not working, rewrite the code for both functions and check them in the main: #include<iostream> #include<cassert> using namespace std; struct nodeType {    int info;    nodeType *link; }; class linkedList { public:    void initializeList();    bool isEmptyList();    void print();    int length();    void destroyList();    void insertFirst(int newItem);    void insertLast(int newItem);    int front();    linkedList();    void copyList(const linkedList otherList);    void insertNewValue(int value);...
C++ PROGRAM When I input 3 S P R, it was suppoesed to pop up L...
C++ PROGRAM When I input 3 S P R, it was suppoesed to pop up L W T. But it showed L L L.IDK why the moveNo is not working. I am asking for help, plz dont put some random things on it. main.cpp #include <iostream> #include "computer.h" #include "human.h" #include "referee.h" using namespace std; int main() {     human h;     computer c;     referee r;     r.compare(h,c);     return 0; } computer.cpp #include<iostream> #include "computer.h" using namespace std;...
C++ please Write code to implement the Karatsuba multiplication algorithm in the file linked in Assignment...
C++ please Write code to implement the Karatsuba multiplication algorithm in the file linked in Assignment 2 (karatsuba.cpp) in Canvas (please do not rename file or use cout/cin statements in your solution). As a reminder, the algorithm uses recursion to produce the results, so make sure you implement it as a recursive function. Please develop your code in small The test program (karatsuba_test.cpp) is also given. PLEASE DO NOT MODIFY THE TEST FILE. KARATSUBA.CPP /* Karatsuba multiplication */ #include <iostream>...