Hi All,
I am Just learning c++ about classes and trying to understand the difference between member and method
My code : I have written my own code
When I compile code it shows detail name and age of person 1 and person 2
I don't understand what are member and what are the method in my code.
any help will appreciate
Thanks & warm regards
Gajya Madake
I am Just learning c++ about classes and trying to understand the difference between member and method
My code : I have written my own code
Code:
#include <iostream>
#include <string>
using namespace std;
//A class can be created before main() is called.
class person
{
//The access labels Public, Protected and Private are used within classes to set access permissions for the members in that section of the class
public:
string name;
int age;
};
int main()
{
//Create an object of person and then creating separate objects for the two person like this:
person person1;
person person2;
person1.name = "sunil";
person1.age = 15;
person2.name = "Gajya";
person2.age = 16;
cout << person1.name << ": " << person1.age << endl;
cout << person2.name << ": " << person2.age << endl;
return 0;
}
I don't understand what are member and what are the method in my code.
any help will appreciate
Thanks & warm regards
Gajya Madake