Homework Help Question & Answers

Using C++ create a class called person. A person can have a name, address, age. For...

Using C++ create a class called person. A person can have a name, address, age. For this class create a default constructor and parameterized constructor.

Show the main as

int main()

{

}

-----------------------------------------------------

Show how you will define the class and call it in the main. Only create two instances/objects in main using the two created constructors.

0 0
Add a comment
Answer #1
#include <iostream>
#include <string>

using namespace std;

class person {
private:
    string name;
    string address;
    int age;
public:
    person() {

    }

    person(string name, string address, int age) : name(name), address(address), age(age) {

    }
};

int main() {
    person p1;
    person p2("ronaldo", "portugal", 34);
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Using C++ create a class called person. A person can have a name, address, age. For...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coin

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
Free Homework App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.