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...
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....
#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 ";   ...
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 =...
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) {   ...
Need someone to fix my code: #include<iostream> using namespace std; struct student { double firstQuizz; double...
Need someone to fix my code: #include<iostream> using namespace std; struct student { double firstQuizz; double secondQuizz; double midTerm; double finalTerm; string name; }; int main() { int n; cout<<"enter the number of students"<<endl; cin>>n; struct student students[n]; int i; struct student istudent; for(i=0;i<n;i++) {    cout<<"Student name?"; cin >> istudent.name; cout<<"enter marks in first quizz , second quizz , mid term , final term of student "<<i+1<<endl; cin>>students[i].firstQuizz>>students[i].secondQuizz>>students[i].midTerm>>students[i].finalTerm; } for(i=0;i<n;i++) { double marks=0; double score=students[i].firstQuizz+students[i].secondQuizz+students[i].midTerm+students[i].finalTerm; marks=(students[i].firstQuizz*0.25)+(students[i].secondQuizz*0.25)+(students[i].midTerm*0.25)+(students[i].finalTerm*0.50); double totalArrgegateMarks =...
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...
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);...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT