Classes, Public and Private access modifiers in C++ | C++ Tutorials for Beginners #21

preview_player
Показать описание

Best Hindi Videos For Learning Programming:



►C Language Complete Course In Hindi -

►JavaScript Complete Course In Hindi -



►Django Complete Course In Hindi -






Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

#include<iostream>
using namespace std;

//Structure of class
class Animal{

//Private variables accessible only with the help of function.
private:
int leg, eyes, ears;

public:
int sound, speed;
void setData(int a1, int b1, int c1); // Declaration only
void getData()
{
cout<<"The total legs are "<<leg<<endl;
cout<<"The total eyes are "<<eyes<<endl;
cout<<"The total ears are "<<ears<<endl;
cout<<"The sound is "<<sound<<endl;
cout<<"The average speed is "<<speed<<endl;
}

};

//Definition of function setData
void Animal :: setData(int a1, int b1, int c1){
leg = a1;
eyes = b1;
ears = c1;
}


int main(){
Animal Dog;

//You can accress public variables directly
Dog.sound = 56;
Dog.speed = 75;

//Accessing private variables with the help of function
Dog.setData(4, 2, 2);

Dog.getData();
return 0;
}

blackopss
Автор

Time Stamp - 14:59

#include <iostream>
using namespace std;

class Students
{
private:
int roll_no;
string religion;
public:
string f_name;
int standard;
int age;
void setData(int r, string rel); // r stands for roll_no & rel stands for religion.
void getData()
{
cout<<"The roll number of student is "<<roll_no<<endl;
cout<<"The religion of student is "<<religion<<endl;
cout<<"The Father's name of student is "<<f_name<<endl;
cout<<"The standard of student is "<<standard<<endl;
cout<<"The age of student is "<<age<<endl;

}
};

void Students :: setData(int r, string rel)
{
roll_no = r;
religion = rel;
}

int main(){
Students Gulshan;
Gulshan.f_name = "Anil Kumar";
Gulshan.standard = 10;
Gulshan.age = 15;
Gulshan.setData(40, "Hindu");
Gulshan.getData();
return 0;
}

imgullu
Автор

I got 88% marks in my midterm exam due to this playlist hoping best for the final....
Thanks ❤

AmirNiazi
Автор

#include<iostream>
#include<string>
using namespace std;
class Student{
private:
int roll;
public:
string name;
int Class;
void setData(int r);// declared
void getData(){

cout<<"The name of the student is "<<name<<endl;
cout<<"The class of the student is "<<Class<<endl;
cout<<"The roll no. of the student is "<<roll<<endl;
}
};
void Student :: setData(int r){
roll = r;
}
int main(){
Student nikhil;
nikhil.name = "Nikhil";
nikhil.Class = 7;
nikhil.setData(20);
nikhil.getData();

return 0;
}

nikhilsrivastava
Автор

You are the best Harry Bhai ...free online course provider ....😍🥰🥰

mystudiobeats
Автор

#include<iostream>
using namespace std;
class animal{
private:
int age, height, length;
public:
string name, species;
void setdata(int a, int h, int l); //note:a, h, l are just 3 random variables we have used to signify that we will be using 3 integers.
void getdata(){
cout<<"The age of the animal is:"<<age<<endl;
cout<<"The height of the animal is:"<<height<<endl;
cout<<"The length of the animal is:"<<length<<endl;
cout<<"The Name of the animal is:"<<name<<endl;
cout<<"The specie of the animal is:"<<species<<endl;

}
};
void animal::setdata(int i1, int i2, int i3){
age=i1;
height=i2;
length=i3;
}

int main(){
animal Tigger;
Tigger.setdata(5, 3.2, 5.6);
Tigger.name="Tigger: Winnie the Pooh ka Dost";
Tigger.species="Tiger";
Tigger.getdata();

return 0;
}

devanshusahoo
Автор

Harry SIR, i tried a example - 14:47
#include<iostream>
#include<string.h>
using namespace std;
class pen{
private : float price;
string ink_colour;
public :
void get_data()
{
cout<<" Enter price of pen - ";
cin>>price;
cout<<" Enter ink colour of pen - ";
cin>>ink_colour;
}
void prn_data()
{
cout<<" Price of pen : "<<price<<endl;
cout<<" Enter ink colour of pen : "<<ink_colour;
}
};
int main()
{
pen p1;
p1.get_data();
p1.prn_data();
return 0;
}

NXN-mh
Автор

Love from Bangladesh Harry Bhai 🇧🇩🇧🇩❤️
14:45
Here, the example of a class is car
It can have different properties like
- Brand
- Color
- Transmission
- Mileage

nafisahmed
Автор

Thanks Harry Bhai...

Kuch smjh ni aa rha tha aaj jake sara kuch clear hua hai ...

theevi
Автор

Bahut achha lga mujhe, and concept are so easy to understand by watching it. 💯

kumarrajneesh
Автор

the answer i was searching that why classes is used instead of structure is well explained here .

AmarKumar-izgy
Автор

you might be earning good ....
but here you are earning the blessings and good wishes of all struggling students who were looted by the paid training goons after expensive degree expanses and the poeple looted on the name of internship ....god bless. u dear it up

manmeetsinghkhalsa
Автор

class bank
{
private : float transection, loan;
public : int profit, loss;
} ;

sandeep_cse_
Автор

Bro ur video are amazing outstanding but my exams are near kindly complete the course asap

dipesh-singla
Автор

Main pichle 5 dino se aise languages doondh raha tha jo bahut tuff ho sikhne mein time lage baad mein mujhe mili c++ bhai ne use bhi easy bana diya 😢rona aa raha hai

rajmanipandey
Автор

Thanks Harry bhaiya ji for this amazing course that is free of cost!

jersingh
Автор

short and to the point. Your videos saved a lot of time Thanks for making such a great

LokeshSharma-hmjz
Автор

Coded Myself time : 14:50
#include<iostream>
#include<string.h>
using namespace std;

class animal{
private:
char gender;
int babbies;
public:
char name[50];
int legs;
int hands;
void setData(char, int);
void getData();
};

void animal :: setData(char gen, int bab){
gender = gen;
babbies = bab;
}

void animal :: getData(){
cout<<name<<":\n";
cout<<"\t gender : "<<gender;
cout<<"\t babbies : "<<babbies;
cout<<"\t legs : "<<legs;
cout<<"\t hands : "<<hands;

}
int main(){
animal kangaroo, dog;
kangaroo.hands = 2, kangaroo.legs = 2;
strcpy(kangaroo.name, "Kangaroo");
dog.hands = 0, dog.legs = 4;
strcpy(dog.name, "Dog");
kangaroo.setData('M', 3);
dog.setData('F', 2);

kangaroo.getData();
cout<<"\n";
dog.getData();

return 0;
}


Output :

Kangaroo:
gender : M babbies : 3 legs : 2 hands : 2
Dog:
gender : F babbies : 2 legs : 4 hands : 0

aiexplorations-cvjs
Автор

Class avengers{
Public:
Int speed;
Int health;
Int fire;
Void attack() {
Int attack=speed+fire;
Cout <<attack<<endl;
};

Anurag-fkop
Автор

Very good
Ek request hai plzz data structures par bhi tutorial video bnaye.

surendrakashyap