JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: c++ language in hindi

vector container (basic) in c++ language in hindi , meaning of vector container examples

इससे पहले के article मे , vector array को use किया था लेकिन अब तक हमने discuss नहीं किया है | अब इस article  , vector और valarray को discuss करेगे | जो की c++ language का मुख्य concept होता है |

c++ language मे , template को discuss किया था | template किसी class और function को create करने के लिए  blueprint or formula होता है | उदाहरण के लिए , library containers जैसे  iterators and algorithms generic programming का उदहारण है जो की template concept से बनाया जाता है  |

ठीक उसी प्रकार , c++ language मे , array के लिए दो template होते है |

(1) Vector

(2) Valarray

दोनों ही class template को  अलग अलग purpose के लिए बनाया जाता है |

(1) Vector

Vector template class , container class और  algorithm के सिस्टम का पार्ट होता है | Vector template class , system oriented activity जैसे sorting , insertion , rearrangement , searching को support करता है | इसके अलावा , Vector template class मे किसी data को एक container से दुसरे container मे transfer भी किया जाता है | इसके अलावा manipulator को भी support करता है  | vector को declare करने के लिए निन्म syntax को फॉलो करता है :-

vector <double> v3(10) , v1(10) , v2 (10);

यहा पर

vector : ये vector को declare करने के लिए keyword को use करते है |

<double> : ये vector array के type को define करता है |

v3(10) , v1(10) और  v2 (10) : ये data variable को define किया जाता है | ये सभी values को होल्ड करता है |

इसके अलावा किसी vector को use करने के लिए vector को begin किया जाता है इसके लिए begin () function को use किया जाता है |

इसके लिए vector_variable name . begin() syntax है जिसमे vector_variable name : इसे vector को declartion मे declare किया जाता है  | और इसके अलावा किसी vector को use करने के बाद  vector को end किया जाता है इसके लिए  end() function को use किया जाता है |

इसके लिए vector_variable name . end() syntax है जिसमे vector_variable name : इसे vector को declartion मे declare किया जाता है  |

किसी vector के variable मे operation को perform किया जाता है | अगर किसी  दो array के elements को add करके किसी तीसरे array मे assign किया जाता है |

इसके लिए निन्म code को use किया जाता है :-

transform(v1.begin(),v1.end(),v2.begin(),v3.begin())

इसके बाद v3 = v1 + v2 ;

इसके अलावा vector से releated कुछ function निन्म है :-

Iterators

begin() – इस function का use किसी iterator को return करने के लिए किया जाता है जिसे किसी vector के first element को point किया जाता है |

end() – इस function का use किसी iterator को return करने के लिए किया जाता है जिसे किसी vector के last element को point किया जाता है |

rbegin() – इस function का use किसी reverse iterator को return करने के लिए किया जाता है जिसे किसी vector के last element को point किया जाता है | क्योकि इसमें transversing reverse order मे होता है |

rend() – इस function का use किसी reverse iterator को return करने के लिए किया जाता है जिसे किसी vector के first element को point किया जाता है | क्योकि इसमें transversing  reverse order मे होता है |

cbegin() – इस function का use किसी  constant iterator को return करने के लिए किया जाता है जिसे किसी vector के first element को point किया जाता है |

cend() –  इस function का use किसी  constant iterator को return करने के लिए किया जाता है जिसे किसी vector के  last element को point किया जाता है |

crbegin() – इस function का use किसी constant reverse iterator को return करने के लिए किया जाता है जिसे किसी vector के last element को point किया जाता है | क्योकि इसमें transversing reverse order मे होता है |

crend() –  इस function का use किसी constant reverse iterator को return करने के लिए किया जाता है जिसे किसी vector के first element को point किया जाता है | क्योकि इसमें transversing reverse order मे होता है | इस transversing मे ,vector का first element last element होगा |

नीचे दिए गये उदाहरन मे vector के उदाहरन को discuss करेगे |

// C++ program to illustrate the

// iterators in vector

#include <iostream>

#include <vector>

using namespace std;

void  main()

{

vector<int> v1;

for (int i = 1; i <= 5; i++)

v1.push_back(i); // इससे vector मे data variable को assign किया जाता है  //

cout << “Output of begin and end: “;

for (auto i = v1.begin(); i != v1.end(); ++i)

cout << *i << ” “;

cout << “\nOutput of cbegin and cend: “;

for (auto i = v1.cbegin(); i != v1.cend(); ++i)

cout << *i << ” “;

cout << “\nOutput of rbegin and rend: “;

for (auto ir = v1.rbegin(); ir != v1.rend(); ++ir)

cout << *ir << ” “;

cout << “\nOutput of crbegin and crend : “;

for (auto ir = v1.crbegin(); ir != v1.crend(); ++ir)

cout << *ir << ” “;

getch();

}

Output:

Output of begin and end: 2 3 4 3 1

Output of cbegin and cend: 2 3 4 3 1

Output of rbegin and rend: 1 3 4 3 2

Output of crbegin and crend : 1 3 4 3 2

इस article मे vector template class के कुछ ही function को discuss किया है अब आगे के article मे , vector template class के कुछ advance function को discuss करेगे |

Sbistudy

Recent Posts

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

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

10 hours ago

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

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

10 hours ago

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

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

2 days ago

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

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

2 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