bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_2 / eduincs / pgrm_003.cpp

pgrm_003.cpp (419B)


      1 /* class - object */
      2 
      3 #include<iostream>
      4 using namespace std;
      5 
      6 class person {
      7     public:
      8         int age;
      9         string name;
     10 
     11         void setName(string n) {
     12             name = n;
     13         }
     14 
     15         void setAge(int a) {
     16             age = a;
     17         }
     18 };
     19 
     20 int main() {
     21     person p;
     22     p.setName("Amit Dutta");
     23     p.setAge(19);
     24     cout << "Name: " << p.name << endl;
     25     cout << "Age: " << p.age;
     26     return 0;
     27 }