Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C++
include <iostream>
using namespace std;
class person
{
  char name[30];
  int age;
  public: void getdata(void);
  void display(void);
};

void person : getdata(void)
  cout << "Enter name: ";
  cin>> namé;
  cout << "Enter age: ";
  cin>> age; 
}

void person :: display (void)
  cout << "\nName: " << name;
  cout << "\nAge: " << age;
}

int main() {
  person p;
  p.getdata();
  p.display();
  return 0;
}


What I have tried:

Any one please explain this program clearly. I'm a student.
Posted
Updated 19-Jun-20 7:15am
v3
Comments
Garth J Lancaster 19-Jun-20 4:10am    
Why dont you give it a shot, it isnt complex - use 'Improve question' and add at the bottom what you think it is doing - start at the
int main() {}
block of code....We'll then help and comment - else it looks like we're doing your homework for you
btw, I reformatted your code and added some spaces, I didnt fix the typing errors

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
But that code? It won't even compile, much less run ... the class is incomplete, the name variabel is mispelled, part of a line of code is missing, there is no '#' in front of "include", ... just try and compile it an you will get a list of problems!

Fix your compiler errors, then try to explain it to yourself.
 
Share this answer
 
Check out (and read) one or more of the many many many freely available tutorial on the topic. Try, for instance: C++ OOP (Object-Oriented Programming)[^].
 
Share this answer
 
It is a small boilerplate C++ program with a tiny class person and usage of some std-libraries. Not very well written.

If your are interest in C++ than read the Learn C++ tutorial and my How to Start the Homework or a Developer Career.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900