Write a c++ program to create a base class called STUDENT ... |
1 2 3 4 5 6
|
class Student
{
protected:
char name [20];
int rn,age;
};
|
That isn't an object. It's a record, or in C speak, a struct.
An object is something that you can only communicate with using messages. In C++ that is, by calling member methods. You cannot access object data directly. This is why that isn't an object.
To make it an object, you need to provide a set of methods that the object will support, and implement them. Object methods are virtual functions in C++.
Plus, C++ requires you to consider initialization, copy and destruction too.
Object oriented programming in C++ only works when object methods are implemented with virtual functions and the objects themselves are accessed thru inderection; that is, thru a pointer or reference.
It is not normal for object methods to ask for user input for the application. For example, consiter string::clear(). What do you think would happen if that method prompted for verification first? You'd have this prompt every time it was used. But clearly, verification has little to do with actually clearing the string, so the prompt isn't part ot it. And it shouldn't be part of your methods also.