pgrm_003.cpp (555B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 29 Jun 2026 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* class - object */ 8 9 #include<iostream> 10 using namespace std; 11 12 class person { 13 public: 14 int age; 15 string name; 16 17 void setName(string n) { 18 name = n; 19 } 20 21 void setAge(int a) { 22 age = a; 23 } 24 }; 25 26 int main() { 27 person p; 28 p.setName("Amit Dutta"); 29 p.setAge(19); 30 cout << "Name: " << p.name << endl; 31 cout << "Age: " << p.age; 32 return 0; 33 }