I was just playing with classes for the first time...
please see the code below..
Code:#include <iostream.h> #include <stdio.h> class person { char name[30]; public: void get****(); void show****(); int age; }; void person :: get****() { cout << "Enter name : "; cin >> name; cout << "Enter age : "; cin >> age; } void person :: show****() { cout << "Name: "<< name << endl; cout << "Age: " << age << endl; } class anotherclass { public: int huh; void anotherfunc(); }; void anotherclass :: anotherfunc() { huh = 5; } main() { int i; person someone[2]; anotherclass someone1; for(i=0; i<=1; i++) { someone[i].get****(); } for(i=0; i<=1; i++) { someone[i].show****(); } cout << "age "<< someone[0].age << endl; cout << someone1.huh << endl; getchar(); }
now, I can access someone[0].age variable without any problem..
why can't i access someone1.huh ?