What is Constructor in C++ in Hindi

What is Constructor in c++ in Hindi with Example:- Hello Friend Mera Naam Shubham Hai, & I am Back With QA Series Of C++ in Hindi & today’s topic is all about What is Constructor in C++ In Hindi.

What is Constructor in c++ in Hindi (Constructor kya hai)

Constructor Ek Tarah ka Member Function Hota hai, Jo ki Class me Kisi Bhi prakar ke Object Ko Initialize Karta Hai.

Constructor Ke bare me Kuch important point hai Jo main Apko Batana Cahugaa.

  • Name of Constructor is based on Class (Same as Class)
  • It doesn’t require “void” also no return type as Function.
  • it Runs automatically as an object of a class created.
  • The constructor is a special member of a class can be used to initiate  The object of a class.
  • it is the best way to initiate the Object.

jab class me Koi Bhi New Object Create kiya jaata Hai To Constructor call hota hai Aur Usme diye Sabhi Statement Execute Hote hai.

Constructor ko Class ke Ander Bhi Define kiya ja Sakta hai Aur bahar Bhi define kiya jaa Sakta hai.

Here Is Constructor Program Example

#include<iostream.h>

#include<conio.h>

#include<string.h>

class student

{private:

int rno;

char name[20];

char cls[15];

int fees;  

public:

void get()

{ cout<<“Enter roll no= “;      cin>>ron;

cout<<“Enter Student Name= “;    cin>>name;

cout<<“Enter Class= “;     cin>>cls;

cout<<“Enter Fees= “;     cin>>fees;

}    void show()

{  cout<<rno<<“\t”<<name<<“\t”<<cls<<“\t”<<fees;

}  

student()

{rno = 1501;

strcpy(name , “Ravi”);

strcpy(cls , “Bsc(cs)”);

fees = 6000;

}  };

void main()

{ clrscr();

student s1, s2;

s2.get();

s1.show();

s2.show();

getch();

}

Is Program me Jo Values Maine Constructor Me provide ki hui hai. jab Ham s1 object me show()  function ka Use Karege To hame Constructor ki values Show Hogi Kyuki Hamne s1 Object me Data input Nahi Kiya Hai…

What Is Constructor In C++ In Hindi Video Guide

Video Credit: easytuts4you

Thankyou For Reading This Post. If you like it Then Shares With Your Friends On Social Media.

If You Have Any Question Regarding Constructor in C++ Then Let me Know With Your Comments:)

Related Post:

What is inheritance in c++ in Hindi complete guide

What Is Friend Function in C++ With Example In Hindi

What is Copy Constructor in C++ Explain With Example in Hindi

More Tags: What is Constructor in C++, How to define Constructor, Constructor and Destructor in Hindi, Constructor Examples, What Does Mean By Constructor.

3 COMMENTS

    • No It’s Not that hard.. Aap kosis kijiyee C ko thoda sa time dene ki, aur koi bhi problem c language me ho to Aap mujse puch sakte hai.

      Best
      Shubham..

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.