This is just simple code to practice the use of virtual functionsvirtual functions from a practice challenge in HackerRank. Could you give me some advice about the best practices and style?
int main(){
int main(){
int n, val;
std::cin>>n; //The number of objects that is going to be created.
Person *per[n];
for(int i = 0;i < n;i++){
std::cin>>val;
if(val == 1){
// If val is 1 current object is of type Professor
per[i] = new Professor;
}
else per[i] = new Student; // Else the current object is of type Student
per[i]->getdata(); // Get the data from the user.
}
for(int i=0;i<n;i++)
per[i]->putdata(); // Print the required output for each object.
return 0;
}