How to use struct members in a struct's member function?












0














So the purpose of the program is to Create an array of 3 people, allow the user to populate the data in a for loop, ensure that the results are capitalized, and output the results.
These new projects instructions were to
1. Rewrite capitalize() as a method within the structure.
2. Rewrite printPerson() as a method within the structure



The program itself works just fine, it's just not in the format that my professor wanted. He said the point of it is to not use any arguments but again, I don't know what he means. I just started programming a few months ago and even though I'm trying I don't have a strong knowledge of the terminology.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
string firstName;
string middleName;
string lastName;
int age;
string gender;

void capitalize(Person &arg);
void printPerson(Person arg);
};


Pretty sure these are the methods right here, but I'm not sure if the (person &arg) and (person arg) are the arguments itself or if they are parameters. I thought it was the "arg" part but I can't find a way to get the program to run without them as I'm pretty sure I need the & of operator to modify the information.



int main(void) {
Person myPerson;
Person a[3];
const int size = 5;

for (int i = 0; i <= 2; i++) {
cout << "What is First Name #" << i + 1 << "? ";
getline(cin, a[i].firstName);
cout << "What is Middle Name #" << i + 1 << "? ";
getline(cin, a[i].middleName);
cout << "What is Last Name #" << i + 1 << "? ";
getline(cin, a[i].lastName);
cout << "Age #" << i + 1 << "? ";
cin >> a[i].age;
cin.ignore();
cout << "Male or Female #" << i + 1 << "? ";
getline(cin, a[i].gender);
cout << endl;
}

for (int i = 0; i <= 2; i++) {
myPerson.capitalize(a[i]);
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
myPerson.printPerson(a[i]);
}

system("pause");
return 0;
}


Along with that, I don't know how to manipulate the functions to work without the "parameters/arguments" (I'm not sure the difference at this point) or without the "arg"



void Person::capitalize(Person &arg) {
transform(arg.firstName.begin(), arg.firstName.end(), arg.firstName.begin(), ::toupper);
transform(arg.middleName.begin(), arg.middleName.end(), arg.middleName.begin(), ::toupper);
transform(arg.lastName.begin(), arg.lastName.end(), arg.lastName.begin(), ::toupper);
}

void Person::printPerson(Person arg) {
cout << "nFirst Name: " << arg.firstName << endl;
cout << "nMiddle Name: " << arg.middleName << endl;
cout << "nLast Name: " << arg.lastName << endl;
cout << "nAge: " << arg.age << endl;
cout << "nGender: " << arg.gender << endl;
cout << "nn";
}









share|improve this question




















  • 1




    I would suggest that you read some good books. This is very basic stuff.
    – ravnsgaard
    Nov 12 '18 at 22:20










  • "not use any arguments but again, I don't know what he means." You are saying you do not know what an 'argument' is? Did you try to look it up? For example, try looking up "argument c++". (either on-line or in a c++ book)
    – 2785528
    Nov 12 '18 at 23:55
















0














So the purpose of the program is to Create an array of 3 people, allow the user to populate the data in a for loop, ensure that the results are capitalized, and output the results.
These new projects instructions were to
1. Rewrite capitalize() as a method within the structure.
2. Rewrite printPerson() as a method within the structure



The program itself works just fine, it's just not in the format that my professor wanted. He said the point of it is to not use any arguments but again, I don't know what he means. I just started programming a few months ago and even though I'm trying I don't have a strong knowledge of the terminology.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
string firstName;
string middleName;
string lastName;
int age;
string gender;

void capitalize(Person &arg);
void printPerson(Person arg);
};


Pretty sure these are the methods right here, but I'm not sure if the (person &arg) and (person arg) are the arguments itself or if they are parameters. I thought it was the "arg" part but I can't find a way to get the program to run without them as I'm pretty sure I need the & of operator to modify the information.



int main(void) {
Person myPerson;
Person a[3];
const int size = 5;

for (int i = 0; i <= 2; i++) {
cout << "What is First Name #" << i + 1 << "? ";
getline(cin, a[i].firstName);
cout << "What is Middle Name #" << i + 1 << "? ";
getline(cin, a[i].middleName);
cout << "What is Last Name #" << i + 1 << "? ";
getline(cin, a[i].lastName);
cout << "Age #" << i + 1 << "? ";
cin >> a[i].age;
cin.ignore();
cout << "Male or Female #" << i + 1 << "? ";
getline(cin, a[i].gender);
cout << endl;
}

for (int i = 0; i <= 2; i++) {
myPerson.capitalize(a[i]);
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
myPerson.printPerson(a[i]);
}

system("pause");
return 0;
}


Along with that, I don't know how to manipulate the functions to work without the "parameters/arguments" (I'm not sure the difference at this point) or without the "arg"



void Person::capitalize(Person &arg) {
transform(arg.firstName.begin(), arg.firstName.end(), arg.firstName.begin(), ::toupper);
transform(arg.middleName.begin(), arg.middleName.end(), arg.middleName.begin(), ::toupper);
transform(arg.lastName.begin(), arg.lastName.end(), arg.lastName.begin(), ::toupper);
}

void Person::printPerson(Person arg) {
cout << "nFirst Name: " << arg.firstName << endl;
cout << "nMiddle Name: " << arg.middleName << endl;
cout << "nLast Name: " << arg.lastName << endl;
cout << "nAge: " << arg.age << endl;
cout << "nGender: " << arg.gender << endl;
cout << "nn";
}









share|improve this question




















  • 1




    I would suggest that you read some good books. This is very basic stuff.
    – ravnsgaard
    Nov 12 '18 at 22:20










  • "not use any arguments but again, I don't know what he means." You are saying you do not know what an 'argument' is? Did you try to look it up? For example, try looking up "argument c++". (either on-line or in a c++ book)
    – 2785528
    Nov 12 '18 at 23:55














0












0








0







So the purpose of the program is to Create an array of 3 people, allow the user to populate the data in a for loop, ensure that the results are capitalized, and output the results.
These new projects instructions were to
1. Rewrite capitalize() as a method within the structure.
2. Rewrite printPerson() as a method within the structure



The program itself works just fine, it's just not in the format that my professor wanted. He said the point of it is to not use any arguments but again, I don't know what he means. I just started programming a few months ago and even though I'm trying I don't have a strong knowledge of the terminology.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
string firstName;
string middleName;
string lastName;
int age;
string gender;

void capitalize(Person &arg);
void printPerson(Person arg);
};


Pretty sure these are the methods right here, but I'm not sure if the (person &arg) and (person arg) are the arguments itself or if they are parameters. I thought it was the "arg" part but I can't find a way to get the program to run without them as I'm pretty sure I need the & of operator to modify the information.



int main(void) {
Person myPerson;
Person a[3];
const int size = 5;

for (int i = 0; i <= 2; i++) {
cout << "What is First Name #" << i + 1 << "? ";
getline(cin, a[i].firstName);
cout << "What is Middle Name #" << i + 1 << "? ";
getline(cin, a[i].middleName);
cout << "What is Last Name #" << i + 1 << "? ";
getline(cin, a[i].lastName);
cout << "Age #" << i + 1 << "? ";
cin >> a[i].age;
cin.ignore();
cout << "Male or Female #" << i + 1 << "? ";
getline(cin, a[i].gender);
cout << endl;
}

for (int i = 0; i <= 2; i++) {
myPerson.capitalize(a[i]);
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
myPerson.printPerson(a[i]);
}

system("pause");
return 0;
}


Along with that, I don't know how to manipulate the functions to work without the "parameters/arguments" (I'm not sure the difference at this point) or without the "arg"



void Person::capitalize(Person &arg) {
transform(arg.firstName.begin(), arg.firstName.end(), arg.firstName.begin(), ::toupper);
transform(arg.middleName.begin(), arg.middleName.end(), arg.middleName.begin(), ::toupper);
transform(arg.lastName.begin(), arg.lastName.end(), arg.lastName.begin(), ::toupper);
}

void Person::printPerson(Person arg) {
cout << "nFirst Name: " << arg.firstName << endl;
cout << "nMiddle Name: " << arg.middleName << endl;
cout << "nLast Name: " << arg.lastName << endl;
cout << "nAge: " << arg.age << endl;
cout << "nGender: " << arg.gender << endl;
cout << "nn";
}









share|improve this question















So the purpose of the program is to Create an array of 3 people, allow the user to populate the data in a for loop, ensure that the results are capitalized, and output the results.
These new projects instructions were to
1. Rewrite capitalize() as a method within the structure.
2. Rewrite printPerson() as a method within the structure



The program itself works just fine, it's just not in the format that my professor wanted. He said the point of it is to not use any arguments but again, I don't know what he means. I just started programming a few months ago and even though I'm trying I don't have a strong knowledge of the terminology.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
string firstName;
string middleName;
string lastName;
int age;
string gender;

void capitalize(Person &arg);
void printPerson(Person arg);
};


Pretty sure these are the methods right here, but I'm not sure if the (person &arg) and (person arg) are the arguments itself or if they are parameters. I thought it was the "arg" part but I can't find a way to get the program to run without them as I'm pretty sure I need the & of operator to modify the information.



int main(void) {
Person myPerson;
Person a[3];
const int size = 5;

for (int i = 0; i <= 2; i++) {
cout << "What is First Name #" << i + 1 << "? ";
getline(cin, a[i].firstName);
cout << "What is Middle Name #" << i + 1 << "? ";
getline(cin, a[i].middleName);
cout << "What is Last Name #" << i + 1 << "? ";
getline(cin, a[i].lastName);
cout << "Age #" << i + 1 << "? ";
cin >> a[i].age;
cin.ignore();
cout << "Male or Female #" << i + 1 << "? ";
getline(cin, a[i].gender);
cout << endl;
}

for (int i = 0; i <= 2; i++) {
myPerson.capitalize(a[i]);
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
myPerson.printPerson(a[i]);
}

system("pause");
return 0;
}


Along with that, I don't know how to manipulate the functions to work without the "parameters/arguments" (I'm not sure the difference at this point) or without the "arg"



void Person::capitalize(Person &arg) {
transform(arg.firstName.begin(), arg.firstName.end(), arg.firstName.begin(), ::toupper);
transform(arg.middleName.begin(), arg.middleName.end(), arg.middleName.begin(), ::toupper);
transform(arg.lastName.begin(), arg.lastName.end(), arg.lastName.begin(), ::toupper);
}

void Person::printPerson(Person arg) {
cout << "nFirst Name: " << arg.firstName << endl;
cout << "nMiddle Name: " << arg.middleName << endl;
cout << "nLast Name: " << arg.lastName << endl;
cout << "nAge: " << arg.age << endl;
cout << "nGender: " << arg.gender << endl;
cout << "nn";
}






c++ struct parameters arguments






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 0:23









tangoal

315217




315217










asked Nov 12 '18 at 22:02









JayusJayus

1




1








  • 1




    I would suggest that you read some good books. This is very basic stuff.
    – ravnsgaard
    Nov 12 '18 at 22:20










  • "not use any arguments but again, I don't know what he means." You are saying you do not know what an 'argument' is? Did you try to look it up? For example, try looking up "argument c++". (either on-line or in a c++ book)
    – 2785528
    Nov 12 '18 at 23:55














  • 1




    I would suggest that you read some good books. This is very basic stuff.
    – ravnsgaard
    Nov 12 '18 at 22:20










  • "not use any arguments but again, I don't know what he means." You are saying you do not know what an 'argument' is? Did you try to look it up? For example, try looking up "argument c++". (either on-line or in a c++ book)
    – 2785528
    Nov 12 '18 at 23:55








1




1




I would suggest that you read some good books. This is very basic stuff.
– ravnsgaard
Nov 12 '18 at 22:20




I would suggest that you read some good books. This is very basic stuff.
– ravnsgaard
Nov 12 '18 at 22:20












"not use any arguments but again, I don't know what he means." You are saying you do not know what an 'argument' is? Did you try to look it up? For example, try looking up "argument c++". (either on-line or in a c++ book)
– 2785528
Nov 12 '18 at 23:55




"not use any arguments but again, I don't know what he means." You are saying you do not know what an 'argument' is? Did you try to look it up? For example, try looking up "argument c++". (either on-line or in a c++ book)
– 2785528
Nov 12 '18 at 23:55












1 Answer
1






active

oldest

votes


















0














The capitalize and the printPerson are now members (usually called methods) of the struct Person. This means that they operate on the member variables of an Person instance. Like this, you can just access all the classes members in these methods. See the following code. I also completed it with a constructor and made it slightly more readable.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
public:
Person();
void readFromUserInput();
void capitalize();
void print();
public:
string firstName;
string middleName;
string lastName;
int age;
string gender;
};

Person::Person() :
firstName(""),
middleName(""),
lastName(""),
age(0),
gender("")
{

}

void Person::readFromUserInput()
{
cout << "What is the First Name ? ";
getline(cin, firstName);

cout << "What is Middle Name ? ";
getline(cin, middleName);

cout << "What is Last Name ? ";
getline(cin, lastName);

cout << "Age ? ";
cin >> age;
cin.ignore();

cout << "Male or Female ? ";
getline(cin, gender);
}

void Person::capitalize()
{
transform(firstName.begin(), firstName.end(), firstName.begin(), ::toupper);
transform(middleName.begin(), middleName.end(), middleName.begin(), ::toupper);
transform(lastName.begin(), lastName.end(), lastName.begin(), ::toupper);
}

void Person::print()
{
cout << "nFirst Name: " << firstName << endl;
cout << "nMiddle Name: " << middleName << endl;
cout << "nLast Name: " << lastName << endl;
cout << "nAge: " << age << endl;
cout << "nGender: " << gender << endl;
cout << "nn";
}

int main(void)
{
const int NUM_PERSONS = 3;
Person a[NUM_PERSONS];

for (int i = 0; i < NUM_PERSONS; i++)
{
cout << "### " << (i + 1) << ". User:" << endl;
a[i].readFromUserInput();
cout << endl;
}

for (int i = 0; i < NUM_PERSONS; i++)
{
a[i].capitalize();
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
a[i].print();
}

system("pause");
return 0;
}





share|improve this answer





















  • thank you dude, this was actually really helpful
    – Jayus
    Nov 13 '18 at 3:35











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270755%2fhow-to-use-struct-members-in-a-structs-member-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The capitalize and the printPerson are now members (usually called methods) of the struct Person. This means that they operate on the member variables of an Person instance. Like this, you can just access all the classes members in these methods. See the following code. I also completed it with a constructor and made it slightly more readable.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
public:
Person();
void readFromUserInput();
void capitalize();
void print();
public:
string firstName;
string middleName;
string lastName;
int age;
string gender;
};

Person::Person() :
firstName(""),
middleName(""),
lastName(""),
age(0),
gender("")
{

}

void Person::readFromUserInput()
{
cout << "What is the First Name ? ";
getline(cin, firstName);

cout << "What is Middle Name ? ";
getline(cin, middleName);

cout << "What is Last Name ? ";
getline(cin, lastName);

cout << "Age ? ";
cin >> age;
cin.ignore();

cout << "Male or Female ? ";
getline(cin, gender);
}

void Person::capitalize()
{
transform(firstName.begin(), firstName.end(), firstName.begin(), ::toupper);
transform(middleName.begin(), middleName.end(), middleName.begin(), ::toupper);
transform(lastName.begin(), lastName.end(), lastName.begin(), ::toupper);
}

void Person::print()
{
cout << "nFirst Name: " << firstName << endl;
cout << "nMiddle Name: " << middleName << endl;
cout << "nLast Name: " << lastName << endl;
cout << "nAge: " << age << endl;
cout << "nGender: " << gender << endl;
cout << "nn";
}

int main(void)
{
const int NUM_PERSONS = 3;
Person a[NUM_PERSONS];

for (int i = 0; i < NUM_PERSONS; i++)
{
cout << "### " << (i + 1) << ". User:" << endl;
a[i].readFromUserInput();
cout << endl;
}

for (int i = 0; i < NUM_PERSONS; i++)
{
a[i].capitalize();
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
a[i].print();
}

system("pause");
return 0;
}





share|improve this answer





















  • thank you dude, this was actually really helpful
    – Jayus
    Nov 13 '18 at 3:35
















0














The capitalize and the printPerson are now members (usually called methods) of the struct Person. This means that they operate on the member variables of an Person instance. Like this, you can just access all the classes members in these methods. See the following code. I also completed it with a constructor and made it slightly more readable.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
public:
Person();
void readFromUserInput();
void capitalize();
void print();
public:
string firstName;
string middleName;
string lastName;
int age;
string gender;
};

Person::Person() :
firstName(""),
middleName(""),
lastName(""),
age(0),
gender("")
{

}

void Person::readFromUserInput()
{
cout << "What is the First Name ? ";
getline(cin, firstName);

cout << "What is Middle Name ? ";
getline(cin, middleName);

cout << "What is Last Name ? ";
getline(cin, lastName);

cout << "Age ? ";
cin >> age;
cin.ignore();

cout << "Male or Female ? ";
getline(cin, gender);
}

void Person::capitalize()
{
transform(firstName.begin(), firstName.end(), firstName.begin(), ::toupper);
transform(middleName.begin(), middleName.end(), middleName.begin(), ::toupper);
transform(lastName.begin(), lastName.end(), lastName.begin(), ::toupper);
}

void Person::print()
{
cout << "nFirst Name: " << firstName << endl;
cout << "nMiddle Name: " << middleName << endl;
cout << "nLast Name: " << lastName << endl;
cout << "nAge: " << age << endl;
cout << "nGender: " << gender << endl;
cout << "nn";
}

int main(void)
{
const int NUM_PERSONS = 3;
Person a[NUM_PERSONS];

for (int i = 0; i < NUM_PERSONS; i++)
{
cout << "### " << (i + 1) << ". User:" << endl;
a[i].readFromUserInput();
cout << endl;
}

for (int i = 0; i < NUM_PERSONS; i++)
{
a[i].capitalize();
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
a[i].print();
}

system("pause");
return 0;
}





share|improve this answer





















  • thank you dude, this was actually really helpful
    – Jayus
    Nov 13 '18 at 3:35














0












0








0






The capitalize and the printPerson are now members (usually called methods) of the struct Person. This means that they operate on the member variables of an Person instance. Like this, you can just access all the classes members in these methods. See the following code. I also completed it with a constructor and made it slightly more readable.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
public:
Person();
void readFromUserInput();
void capitalize();
void print();
public:
string firstName;
string middleName;
string lastName;
int age;
string gender;
};

Person::Person() :
firstName(""),
middleName(""),
lastName(""),
age(0),
gender("")
{

}

void Person::readFromUserInput()
{
cout << "What is the First Name ? ";
getline(cin, firstName);

cout << "What is Middle Name ? ";
getline(cin, middleName);

cout << "What is Last Name ? ";
getline(cin, lastName);

cout << "Age ? ";
cin >> age;
cin.ignore();

cout << "Male or Female ? ";
getline(cin, gender);
}

void Person::capitalize()
{
transform(firstName.begin(), firstName.end(), firstName.begin(), ::toupper);
transform(middleName.begin(), middleName.end(), middleName.begin(), ::toupper);
transform(lastName.begin(), lastName.end(), lastName.begin(), ::toupper);
}

void Person::print()
{
cout << "nFirst Name: " << firstName << endl;
cout << "nMiddle Name: " << middleName << endl;
cout << "nLast Name: " << lastName << endl;
cout << "nAge: " << age << endl;
cout << "nGender: " << gender << endl;
cout << "nn";
}

int main(void)
{
const int NUM_PERSONS = 3;
Person a[NUM_PERSONS];

for (int i = 0; i < NUM_PERSONS; i++)
{
cout << "### " << (i + 1) << ". User:" << endl;
a[i].readFromUserInput();
cout << endl;
}

for (int i = 0; i < NUM_PERSONS; i++)
{
a[i].capitalize();
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
a[i].print();
}

system("pause");
return 0;
}





share|improve this answer












The capitalize and the printPerson are now members (usually called methods) of the struct Person. This means that they operate on the member variables of an Person instance. Like this, you can just access all the classes members in these methods. See the following code. I also completed it with a constructor and made it slightly more readable.



#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct Person {
public:
Person();
void readFromUserInput();
void capitalize();
void print();
public:
string firstName;
string middleName;
string lastName;
int age;
string gender;
};

Person::Person() :
firstName(""),
middleName(""),
lastName(""),
age(0),
gender("")
{

}

void Person::readFromUserInput()
{
cout << "What is the First Name ? ";
getline(cin, firstName);

cout << "What is Middle Name ? ";
getline(cin, middleName);

cout << "What is Last Name ? ";
getline(cin, lastName);

cout << "Age ? ";
cin >> age;
cin.ignore();

cout << "Male or Female ? ";
getline(cin, gender);
}

void Person::capitalize()
{
transform(firstName.begin(), firstName.end(), firstName.begin(), ::toupper);
transform(middleName.begin(), middleName.end(), middleName.begin(), ::toupper);
transform(lastName.begin(), lastName.end(), lastName.begin(), ::toupper);
}

void Person::print()
{
cout << "nFirst Name: " << firstName << endl;
cout << "nMiddle Name: " << middleName << endl;
cout << "nLast Name: " << lastName << endl;
cout << "nAge: " << age << endl;
cout << "nGender: " << gender << endl;
cout << "nn";
}

int main(void)
{
const int NUM_PERSONS = 3;
Person a[NUM_PERSONS];

for (int i = 0; i < NUM_PERSONS; i++)
{
cout << "### " << (i + 1) << ". User:" << endl;
a[i].readFromUserInput();
cout << endl;
}

for (int i = 0; i < NUM_PERSONS; i++)
{
a[i].capitalize();
cout << "PERSON #" << i + 1 << endl;
cout << "~~~~~~~~~~~~~~~" << endl;
a[i].print();
}

system("pause");
return 0;
}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 23:27









tangoaltangoal

315217




315217












  • thank you dude, this was actually really helpful
    – Jayus
    Nov 13 '18 at 3:35


















  • thank you dude, this was actually really helpful
    – Jayus
    Nov 13 '18 at 3:35
















thank you dude, this was actually really helpful
– Jayus
Nov 13 '18 at 3:35




thank you dude, this was actually really helpful
– Jayus
Nov 13 '18 at 3:35


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270755%2fhow-to-use-struct-members-in-a-structs-member-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini