• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Sql
  • php
  • C program
  • Seo

Codelack.com

  • Home
  • C++
  • networking
  • Sql server
    • what is rdbms | one to one | one to many | many to many relation-codlack
    • sql server create table
    • code rules in sql server
  • ASP.NET
    • control state in asp.net
    • cookie in asp.net
    • datalist control in asp .net
    • Using ASP.NET To Send Email
    • application state in asp.net
    • file upload control in asp.net
  • contact us
  • Data structure
    • what is Data structure
    • doubly linked list program in c
    • Array in data structure
    • circular queue in data structure
    • Linear data structure
    • Delete node at any position in singly linked list
    • dequeue in data structure
    • implementation of stack using a Linked list in data structure
    • implementation of stack using array in data structure
    • linked list algorithm
    • linked list in data structure
  • C
    • continue and break in c
    • history of c programming language
    • array program in c
    • c programming practice questions
    • enumeration in c
    • C programs with solutions
    • Characteristic of c
    • print 1 to 100 without using loop in c program
    • two single dimension 2D array in c
  • php
    • php
    • Variables in PHP
    • Scalar data types in php
    • Output function in php
    • how to use php string functions | example of string function
    • point to point configuration
    • error in php
    • Array in  php

constructor in c++

Constructor in c++ is a special member function its name is same as the class name.

  • The constructor is invoked automatically whenever an object of its associated class is  created.
  • It  is called constructor because it constructs the values of the data member of the class.
  • Generally , a constructor should be defined under the public section of a class , so that its object can be created in any function.

types of constructor in c++

there are different types of constructor  available in c++.

  1.  Default constructor

The constructor that accept no parameter is called default constructor.

If a class has no explicit constructor defined , the compiler will supply a default constructor.

The default constructor provided by the compiler does not do anything specific. It simply allocates memory to data members of object.

2.  parameterized constructor

The constructor that can take arguments are called parameterized constructor.

Declaring a constructor with arguments hides the default constructor.

Characteristics of constructor in c++

  1.  They should be declared in the public section.
  2. They are invoked automatically when the objects are created.
  3. They do not have  return (data type) type not even void and there for they cannot return any values.
  4. They can not be inherited, the a derived class can call the  base class constructor.
  5.  They make implicit calls to the operator new and delete when memory allocation is required.
  6. It is not possible to take the address of a constructor.
  7. An object of a class with a constructor cannot be a member of a union.

Note :-

Constructors and destructors have no return type, not even void.

A constructor for a class is needed so that the compiler automatically initializes an object as soon as it is created. A class constructor, if defined , is called whenever a program creates an object of that class.

Before the release of c++11 standard of  C++, constructors of a class were  not allowed to call other constructor had to construct all of its class members  itself. But C++11  standard allows constructors of the same class.

  • Default Argument In C++
  • Friend Function In C++
  • Why we use jagged array in c# ?

Primary Sidebar

sql

  • introduction of sql
  • database management system
  • hierarchical database management system
  • what is rdbms | one to one | one to many | many to many relation-codlack
  • codd rules in sql server
  • Character Data Type
  • constraint unique
  • sql server create table

Ads

data structure

  • Data structure
  • Linear data structure
  • Array in data structure
  • What is a algorithm
  • stacks in data structure
  • queue data structure
  • dequeue in data structure
  • Priority queue
  • circular queue in data structure
  • linked list algorithm
  • Delete node in singly linked list
  • tree in data structure
  • implementation of stack using array in data structure
  • implementation of stack using a Linked list in data structure
  • Doubly Linked List Implementation

C programming

  • history of c programming language
  • C programs with solutions
  • Characteristic
  • constraint unique
  • continue and break
  • doubly linked list program in c
  • dynamic memory allocation
  • enumeration
  • print 1 to 100 without using loop
  • Variable declaration

c++

  • Introduction to C++ | similarities of  C++ structure and  class
  • default argument in c++
  • access specifiers in c++
  • Function In C++
  • friend function in c++
  • constructor in c++
  • destructor in c++ | How to call destructor C++
  • exception handling in c++

Categories

array multiplication (1) asp.net (10) B.ed (1) C# (1) c# (1) C++ (2) C program (3) FormView control (1) php (2) Seo (5) Sql (1) Uncategorized (12)
disclaimer

Copyright © 2022 · codelack.com