LLearnViaNotes @learnvianotes· 1 min read A class is a blueprint. An object is a real instance of that blueprint with its own state.
C++class Teacher {
public:
string name;
string subject;
int salary;
void display() {
cout << name << " teaches " << subject;
}
};
// Creating objects
Teacher t1; // t1 is an object
t1.name = "Rahul"; // dot operator
t1.subject = "C++";
t1.display();
Free for students and teachers
Write notes like this one
Cards for every idea, quizzes and flashcards, read aloud — on the web and your phone.
Something wrong with this note? Open it to report