C++ Objects Memory Allocation & using Arrays in Classes | C++ Tutorials for Beginners #23

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
Рекомендации по теме
Комментарии
Автор

// arays in classes

#include<iostream>
using namespace std;

class poultry
{
int chickTagNo[50];
int chickPrice[50];
int increment;
public :
void init_increment(){ increment = 0;}
void setPrice();
void displayPrice();
};

void poultry :: setPrice(){

cout<<"Enter the tag no of the chicken :"<<increment+1<<endl;
cin>>chickTagNo[increment];

cout<<"Enter the Price of the chicken :"<<endl;
cin>>chickPrice[increment];
increment++;

}

void poultry :: displayPrice(){

for (int i=0; i<increment;i++)
{
cout<<"The price of chicken with tagNo :"<<chickTagNo[i]<<" is :"<<chickPrice[i]<<endl;
}
}
int main(){
poultry chicken;
chicken.init_increment();
for(int i=0;i<3;i++){
chicken.setPrice();
}
chicken.displayPrice();
return 0;

}

sumitvishwakarma
Автор

Topic :Competitive programming, please make video how much it is necessary and how can we continue it with development. Thank you.

arpanchowdhury
Автор

Ager topic wise ap 1-2 questions solve kree to or accha rhega hmare liye

ayushchaturvedi.
Автор

i modified it even though it took 30 mins, but it was worth it, and now it can take id and price of (n no. of inputs) . damn i am proud of my self right now.

ayushchauhan
Автор

//Author :Harman kaur
//purpose : Arrays in classes

#include <iostream>
using namespace std;

class shop
{
private:
int itemid[10];
int price[10];
int counter;
int sum = 0 ;
public:
void counts(void) { counter = 0; }
void itemid_price(void);
void display(void);
void total_items(void);
void total_price(void);
};

void shop::itemid_price(void)
{
cout<<"Enter the ID of item no "<< counter + 1<<endl;
cin>>itemid[counter];
cout<<"Enter the price of item\n";
cin>>price[counter];
counter++;
}

void shop::display(void)
{ for (int i = 0; i < counter; i++)
{
cout<<"The price of item Id "<<itemid[i]<<" is "<<price[i]<<endl;
}
}
void shop :: total_items(void){
cout<<"Total number of items are "<<counter<<endl;
}
void shop :: total_price(void){
for (int i = 0; i < counter; i++)
{
sum = sum + price[i];
}
cout<<"The total price is "<<sum;
}
int main()
{
shop s;
s.counts();
s.itemid_price();
s.itemid_price();
s.itemid_price();
s.display();
s.total_items();
s.total_price();
return 0;
}

harmankaur
Автор

Thank u so much harry sir its very helpful for me now i like c++ programming 😊

dhanashrigajare
Автор

Thank you Harry for the complete and free course.

shubhamchaudhary
Автор

Samajh gaya guruji. One shot me video clear.

AshutoshKumar-fuqe
Автор

Thank you so much ☺️.. ur videos very useful for me🙏

bushramuneer
Автор

harry bro, why we use dynamic allocation if we can do like this:
int n;
cin>>n;
int array[n];

_krishsharma_
Автор

pls explain the following doubt - in display price we took i<counter where at first i = 0, during the first iteration due to initcounter function counter = 0, so i<counter contidition should fail right ? so where i am wrong ?

Innocent_Kitten
Автор

This Tutorial playlist is just awesome...Thank you so much HARRY BHAI

arindambala
Автор

i really appreciate the way you teach making topics so easy to understand. thanks a lot for your efforts 🤗

vedashripotu
Автор

Thanks for this helpful video...
Samaj gaya harry bhai..clear hai

csssatyamjadhav
Автор

I am understanding some of the codes and I am so proud of myself. Last night I wrote 50 line code ; ;

nehanidhi
Автор

After learning which topics in C++, I could start solving basic Cpp problems?

anushkajaiswal
Автор

cin>>itemid[counter]; why we used the coounter in it please explain?

uzairahmad
Автор

Visual studio code roo raha h mera 🤣😂😅 Hilarious harry 🙌

rocksalt
Автор

harry bhaiya jo har place pe ap agar void use kar rhe hai is matlab kya he ki wo koi v integer value return nhi kare ga

harshagarwal
Автор

line 11 me jo aapne counter declare krne ke liye function banaya he uski jagah line 9 me declare kr sakte the counter=0; prkyu nahi kiya aisa

shivanshpatel