JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: c++ language in hindi

object array in c++ language in hindi , what is source code program for object array in c++

what is source code program for object array in c++ , object array in c++ language in hindi
इससे पहले के article मे , this pointer को discuss किया था जो की c++ class और object थ्योरी का एक महतवपूर्ण concept है अब इस article मे object की array को discuss करेगे |Array of Object
जब किसी class के एक या एक से अधिक object को declare किया जाता है तब object की array को declare किया जाता है | इस case मे , एक नए ही object syntax को declare किया जाता है | इस object variable को अलग variable की तरह से consider किया जाता है | object array का syntax नार्मल array की तरह होता है | इसका syntax निन्म होता है :-
class_name object_name[size];
यहा पर
class_name : ये class का नाम होता है जिसके लिए object को declare किया जाता है |
object_name : ये object का नाम होता है जिससे class के element को use किया जा सकता है |
प्रोग्राम हमेशा default class constructor को use किया जाता है लेकिन class object को create किया जाता है |जो की explicit initailized किया जाता है | declartion मे दो पॉइंट्स को include किया जाता है :-
1.class जो की default constructor को explicit call किया जाता है | इस case मे implicit defualt constructor को call नहीं किया जाता है |

और इस object class के लिए ओब्जेक्टे array के element को use करने के लिए निन्म syntax को use किया जाता है :-
object_name[index];

इस object को initail करने एक लिए निन्म default construtor को declare करते है |
class_name object_name [size] = {
class_name {class values },;
class_name {class value },
…………………….,
…………………….
};
इस syntax मे, object array की size और default constructor मे declare value की सख्या match होती है |

इसका उदाहरन निन्म है :
const stock & stock1 :: greator(const stock & stock2  )
{
if(total > stock2.total)
{
return total;
}
return *this  ;
}
class stock
{
char company [50];
int share ;
double sharevalue ;
double total ;
void set_total (){total = share value * share ;}
public :
stick ();
void buy();
void sell();
void show();
void update ();
const stock & stock :: greator(const stock & stock  )const ;
}
#include<iostream>
#include<conio.h>
stock :: stock (const char * compnany , int n =0 , double price = 0.0 )
{
std :: strcpy ( name ,company,50 );
company[50]=’\0′;
if(n<0)
{
std::cerr<<“share can not be negetive “;
<< we set share equal to ‘0’ “<<endl;
share = 0 ;
}
else
share = n ;
share_price = price ;
total ();
}
stock :: ~stock ()
{
std :: cout<<“Stock Management Syatem Close “<<Bye ;
}
stock :: buy()
{
if(n<0)
{
std::cerr<<“share purchase can not be negetive “;
<< Please enter share more than ‘0’ “<<endl;
share = 0 ;
}
else
share += n ;
share_price = price ;
total ();
}
stock :: sell()
{
if(n<0)
{
std::cerr<<“share sell can not be negetive “;
<< Please enter share more than ‘0’ “<<endl;
share = 0 ;
}
else
share -= n ;
share_price = price ;
total ();
}
stock :: show()
{
cout<<“company Name :<<company ;
cout<<“share value  :”<<total ;
cout<<“share number :”<<sharevalue
}
const stock & stock1 :: greator(const stock & stock2  )
{
if(total > stock2.total)
{
return total;
}
return *this  ;
}
main()
stock s[4]={
stock{“ABC”,12,200.0}
stock{“EFG”,11,100.0}
stock{“UJK”,10,500.0}
stock{“PQR”,12,1000.0}
};
इस उअदारण मे stock class के object array को discuss किया है | जिसकी size 4 है  | इसलिए जब default constructor मे 4 अलग अलग class value से initial किया जाता है |
अलग अलग object के लिए अलग अलाग class type को define किया जाता है :
stock s[4]={
stock(“ABC”,12,200.0),
stock(),
stock(“UJK”,10,500.0),
stock(“PQR”,12,1000.0)
};

Sbistudy

Recent Posts

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

21 hours ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

21 hours ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

3 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

3 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now