TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Sunday 21 June 2020

Constructor In C++ | Use Of Constructor In C++ | Definition Of Constructor In C++| Feature Of Constructor In C++| Constructor In C++ In Hindi

Constructor In C++

A constructor is a member function of a class which initializes objects of a class. In C++, Constructor is automatically called when object(instance of class) create. It is special member function of the class.

·         Constructor has same name as the class itself

·         Constructors don’t have return type

·         A constructor is automatically called when an object is created.

·   If we do not specify a constructor, C++ compiler generates a default constructor for us (expects no parameters and has an empty body).

 

image of Constructor In C++ | Constructor In C++ program image

Fig:Constructor In C++

Synatx:

class class name

{

private:

----

----

public:

class name();

data member;

member function;

};

 

Program: 

class BCA

{

private:

int a,b,c;

public:

BCA();//constructor create

void getdata();

};

Feature Of Constructor In C++


·        Constructors are the special members of the class which initialize the 

     object of class.

  • A constructor is automatically invoked at the creation of the object.
  • It is generally used to initialize variables.
  • It has the same name as of class.

It does not have any return type(i.e. void, int, etc).

 

 

 


No comments:

Post a Comment