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...
Utilize the code from last week Add a default, full, and copy constructor. Also add a...
Utilize the code from last week Add a default, full, and copy constructor. Also add a constructor that allows you to specify only the name of the video game with no high score or times played specified. Adjust your code to demonstrate use of all 4 constructors and output of the resulting objects. #include <iostream> #include <string> #include <iomanip> using namespace std; class VideoGame { private:     string name;     int highScore;     int numOfPlays; public:     VideoGame() {        ...
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....
C++ #include<iostream> #include<string> #include<fstream> #include<cstdlib> using namespace std; const int ROWS = 8; //for rows in...
C++ #include<iostream> #include<string> #include<fstream> #include<cstdlib> using namespace std; const int ROWS = 8; //for rows in airplane const int COLS = 4; void menu(); //displays options void displaySeats(char[][COLS]); void reserveSeat(char [ROWS][COLS]); int main() { int number=0; //holder variable char seatChar[ROWS][COLS]; for (int i = 0; i < ROWS; i++) { for (int j = 0; j < COLS; j++) { seatChar[i][j] = '-'; } } int choice; //input from menu bool repeat = true; //needed for switch loop while (repeat...
#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;     }
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 =...
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 ";   ...
can someone edit my c++ code where it will output to a file. I am currently...
can someone edit my c++ code where it will output to a file. I am currently using xcode. #include <iostream> #include <cctype> #include <cstring> #include <fstream> using namespace std; bool inputNum(int [],int&,istream&); void multiply(int[],int,int[],int,int[],int&); void print(int[],int,int,int); int main() {ifstream input; int num1[35],num2[35],len1,len2,num3[60],len3=10,i; input.open("multiplyV2.txt"); //open file if(input.fail()) //is it ok? { cout<<"file did not open please check it\n"; system("pause"); return 1; }    while(inputNum(num1,len1,input)) {inputNum(num2,len2,input); multiply(num1,len1,num2,len2,num3,len3); print(num1,len1,len3,1); print(num2,len2,len3,2); for(i=0;i<len3;i++) cout<<"-"; cout<<endl; print(num3,len3,len3,1); //cout<<len1<<" "<<len2<<" "<<len3<<endl; cout<<endl;    } system("pause"); } void...
Write a program that reads a string and outputs the number of lowercase vowels in the...
Write a program that reads a string and outputs the number of lowercase vowels in the string. Your program must contain a function with a parameter of a char variable that returns an int. The function will return a 1 if the char being passed in is a lowercase vowel, and a 0 for any other character. The output for your main program should be: There are XXXX lowercase vowels in string yyyyyyyyyyyyyyyyyyyyyy Where XXXX is the count of lowercase...
Hello, I feel like I am super close but I can not figure out why my...
Hello, I feel like I am super close but I can not figure out why my C++ code it not displaying the proper medium. Thank you! Here is an example of the output: Input : a[] = {1, 3, 4, 2, 6, 5, 8, 7} Output : Mean = 4.5 Median = 4.5 Code so far:   #include <iostream> using namespace std; int main() { int a[100]; int n,i,sum=0; float mean, medium; //read array size // read array cout<<"Enter array size:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT