Day 20: Beginning with OOP-C++ Series
OOPs concepts in C# have always been reserved for Tuesdays as a prerequisite for teaching Complicated programming and real-time Representationing.
📚 Topic Covered:
🔹 1. what is oop
it is the system of amp plan into objects. Every object is an instance of a class.
🔹 2. shaping amp class
cpp
copy
edit
#include
using namespace std;
class machine {
public:
train brand;
int year;
null displayinfo() {
cout << "brand: " << mark << " year: " << class << endl;
}
};
🔹 cardinal. Creating Objects
cpp
Copy
Edit
int main() {
Car myCar;
myCar.brand = "Toyota";
myCar.year = 2020;
myCar.displayInfo();
return 0;
}
🔹 4. approach specifier:
public – away the family get work accessed
private – exclusive the family get work accessed
protected – exclusive the derivative classes get work accessed
🔹 v. Constructors:
cpp
Copy
Edit
class Student {
public:
string name;
int roll;
Student(string n int r) {
name = n;
roll = r;
}
void display() {
cout << name << " - " << roll << endl;
Comments
Post a Comment