Posts

Showing posts from August, 2018

Template Array/ Class Template in C++

Template Array in C++  In this article we will learn how to make template class which store and print data of different types i.e; int,float,char and string. Solution:  #include <iostream> #include <string> using namespace std; template <typename T> class Array { private:     T *ptr;     int size; public:     Array(T arr[], int s);     void print(); }; template <typename T> Array<T>::Array(T arr[], int s) {     ptr = new T[s];     size = s;     for(int i = 0; i < size; i++)         ptr[i] = arr[i]; } template <typename T> void Array<T>::print() {     for (int i = 0; i < size; i++)         cout<<" "<<*(ptr + i);     cout<<endl; } int main() {     int arr[5] = {1, 2, 3, 4, 5};     Array<int> a(arr, 5);     ...

Introduction to Programming Cs201: GDB Solution

        Comparison between Struct and Class : Struct and class are user defied data types By default struct is a public where as class is private Class implements the principal of encapsulation Objects of a class are created on the heap memory Class is used for re usability where as structure is used for grouping the data in the same structure Struct data members cannot be initialised directly but they can be assigned by the outside the structure Class data members can be initialised directly by the parameter less constructor and assigned by the parameterised constructor.      Please comment,like and share regards,  Hafiz Muhammad Umar Hayat

Assignment No 3 Solution : CS-304 Object Oriented Programming

Multiple Inheritance In C++  Solution: #include<iostream.h> #include<conio.h> #include<string.h> using namespace std; class Item{       protected:       string title;       int price;       public:                Item(){                      title="";                      price=0;                                                                }                      Item(string t,int p)                      {             ...

"Rent a Car company" Test phase using C#.net language

"Rent a Car company" Test phase using C#.net language I have developed this application using console application but you can make it own desire language as well as framework. Code snippet: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TestPhase {     class Program     {                 static void Main(string[] args)         {             int age = 0;             int LincenseActivationDate = 0;             int LincenseCancellationDate = 0;             string city = "";             Console.WriteLine("Please enter your age :");             age =Convert.ToInt32( Console.ReadLine());             Consol...