All lovable people of C++, here are sample snippet code which you guys can make use. I want to say one thing about this article, these snippet codes were written and executed when I was pursuing my MCA (Master of Computer Applications) – Post Graduation, and they were published in the year of 2003. Basically I would like to inform you that, I have launched my first website in the year of 2000, and I was hosted in geocities, but unfortunately that site was not Live as I have not updated the things, so that site has been removed and hosted in a free domain. In that website I have placed some of the valuable snippets which helps and they were used in very aspect, Since C++ is an embodiment for Java.
If you really want to see those snippets, as of now I am pasting below a sample snippet code of C++, and the program name is Program for multiple inheritance.
I have placed all the sample snippets in one HTML page, and here are list of programs which are Listed below:
1) Finding maximum, minimum and sum of the given set of numbers
a) Program for finding maximum, minimum and sum of the array elements ( Without Using Functions )
b) Program for finding maximum, minimum and sum of the array elements ( Using Functions )
c) Program for finding maximum, minimum and sum of the array elements ( Using Templates )
2) Sorting programs using arrays
a) Program for sorting the integer array elements (without using functions)
b) Program for sorting the float array elements (without using functions)
c) Program for sorting the string array elements (without using functions)
d) Sorting of integer, float and character array elements using templates
3) Matrix Operations ( Using Functions )
a) Finding the matrix multiplication through functions
b) Finding the matrix addition through functions
c) Finding the matrix subtraction through functions
d) Program for matrix operations (using functions)
4) Recursion function
a) A program for finding the GCD and LCM using recursion functions
5) Classes for Bank Account, Student information, Library catalog
a) A Class for Bank Account
b) A Class for Student Information
c) A Class for Library Catalog
6) Operator Overloading
a) Creation of complex class with operator overloading
7) Multiple Inheritance
a) Program to demonstrate Multiple Inheritance (using arrays)
8 ) Template Functions
a) Template functions for Min( ) and Max( ) for finding maximum and minimum in a list
9) Programs demonstrating pure virtual functions, multiple inheritance and exception handling
a) Program for virtual function
b) Program for multiple inheritance
c) Program for exception handling
As I cant display all the things in this article, For sample I have pasted one program below – you guys go through it…..
// Program for multiple inheritance
#include<iostream.h>
#include<conio.h>
class baseA //base class
{
protected:
int rollno;
char name[20];
char sex;
public:
void getdata();
void showdata();
};
class baseB
{
protected:
int sub1;
int sub2;
public:
void getdata();
void showdata();
};
class derivedD:public baseA,public baseB
{
int total;
float avg;
public:
void getdata();
void setdata();
void display();
};
void baseA::getdata()
{
cout<<"Enter the rollno,name,sex";
cin>>rollno>>name>>sex;
}
void baseB::getdata()
{
cout<<"Enter the marks in two subjects (sub1,sub2)\n";
cin>>sub1>>sub2;
}
void baseA::showdata()
{
cout<<"Roll No:"<<rollno<<"\n";
cout<<"Name:"<<name<<"\n";
cout<<"Sex:"<<sex<<"\n";
}
void baseB::showdata()
{
cout<<"Subject1"<<sub1<<"\n";
cout<<"Subject2"<<sub2<<"\n";
}
void derivedD::getdata()
{
baseA::getdata(); //this avoids ambiguity
baseB::getdata(); //this avoids ambiguity
}
void derivedD::setdata()
{
total=sub1+sub2;
avg=(float)total/2;
}
void derivedD::display()
{
baseA::showdata(); //this avoids ambiguity
baseB::showdata(); //this avoids ambiguity
cout<<"Total="<<total<<"\n";
cout<<"Average="<<avg<<"\n";
}
void main(void)
{
clrscr();
int n;
derivedD d[20];
cout<<"Enter how many students U want to enter";
cin>>n;
for(int i=0;i<n;i++)
{
d[i].getdata();
d[i].setdata();
}
clrscr();
for(int j=0;j<n;j++)
{
cout<<"\nStudent Information"<<"\n";
cout<<"———————"<<"\n";
d[j].display();
}
getch();
}The above pasted Snippet Code is a basic program of Multiple Inheritance, If you guys really liked the above program, then you can go a head and download the stuff from below link.
Related Entries...
I am back again with some helpful snippet code. Here using JavaScript we can pro actively sort date f ...
Below is the code which is written in JavaScript, we can use this script for bookmarking the particul ...
As per the response from "Asa Dotzler " for my article "Indian Firefox fans are disapp ...
eXtplorer is a web based online file manager (FTP - File Transfer Protocol) which is developed using ...
When I am running my Ajax web application, the application is rendering properly in Mozilla Firefox b ...
Just think what Google Chrome would return when we run browser detection code written in JavaScript ? ...
Internet Browser War has began by the release of Google's new browser called "Chrome", meet ...
This is in addition to my article "Download Google Chrome Browser, its awesome ", Just few ...
Introduction: I would like to say this article going to help most of the developers who are in need ...
As you guys already know that Adobe Flash CS3 is awesome enough, in CS3 we can see more features and ...























One Response
hi…
exellent…