Constructor in C++

Any class needs to be instantiated. A constructor is a special function created by default, used to automatically initialize an object. A constructor is implicitly called whenever an object is created. A constructor is also used to initialize the data mem

# include<iostream.h>

class add

{

int n1,n2,res;

public:

add()

{

cout<<”Inside the default constructor”<<endl;

n1=n2=res=0;

}

void accept()

{

cout<<”Enter two numbers:” <<endl;

cin>>n1;

cin>>n2;

}

A sample Class Structure in C++

A simple Class Structure is explained for the beginners. This is meant for learning C++

#include<iostream.h>

class try1

{

private:

        char name[20];

        int age;

        public:

        void inputdata()

        {

                cout<<”Enter yyour name”<<endl;

                cin>>name;

                cout<<”Enter yyour age”<<endl;

                cin>>age;

        }

        void displaydata()

        {    

     cout<<”Yyour name is:”<<name<<endl;

                cout<<”Yyour age is :”<<age<<endl;

        }

 };  //end of class

 void main()

 {

        try1 t1;

        t1.inputdata();

        t1.displaydata();

               }

Nodes in Linked List

  This is a preliminary lesson for the learners of C. The objective is the acquaitance with the structure of a linked listEssentially the structure of any linked list contains two parts, the data part and the pointer part. The first 4 items in the structure indicate the data part, whereas the last one indicates the pointer part.
 
 
These are called nodes in Linked List
 
 
struct invoice{
char itemno[5];
char itemdesc[30];
float rate;
int qty;
struct invoice *next;
};

Hello Programmers!

Coder Circle aims at creating an open knowledge resources, where the experts will share their codes to reveal the tricks and tips, so that the world is benifited and people gets ample opportunity and time to employ their precious human resources more into uninvented secrets