Templates may be used in many combinations with inheritance. It is possible to combine inheritance and templates because a template class is a class, albeit one with a parameter. Combining these language features allows the parameterization ability of templates to be used in conjunction with the specializing abilities of inheritance. Four combinations of templates and inheritance are presented in this section:
a template class that inherits from another template class,
a non-template class that inherits from a template class,
a template class that inherits from a non-template class, and
a template class that uses multiple inheritance.
Each of these combinations will be illustrated by an example showing how the two features are combined and what advantages are possibly gained by using them together.
Our trainer’s having vast experience in real time environment. If anyone has a dream for their career in software programming, then go for java because it is a popular route to establish and fulfill your dreams.
We offer the best quality and affordable training, so you get trained from where you are, from our experienced instructors, remotely using Webex / Gotomeeting.
Our trainer’s having vast experience in real time environment. If anyone has a dream for their career in software programming, then go for java because it is a popular route to establish and fulfill your dreams.
We offer the best quality and affordable training, so you get trained from where you are, from our experienced instructors, remotely using Webex / Gotomeeting.
This whole C++ course focus on giving the insight of different kind of data structures that could be used while dealing with a variety of data that needs to be stored depending upon the circumstances.
The course also focus on how to reduce the complexity of a code by teaching us the variety of approaches that could be employed for a solving the same problem.
Here I discuss about Java programming language and easiest way to solve programming problem. Java basic syntax and their uses are described briefly so that anyone can easily understand within very short time. If anyone follow the slide with proper way,I assure that he or she will find java programming interesting.
This whole C++ course focus on giving the insight of different kind of data structures that could be used while dealing with a variety of data that needs to be stored depending upon the circumstances.
The course also focus on how to reduce the complexity of a code by teaching us the variety of approaches that could be employed for a solving the same problem.
Here I discuss about Java programming language and easiest way to solve programming problem. Java basic syntax and their uses are described briefly so that anyone can easily understand within very short time. If anyone follow the slide with proper way,I assure that he or she will find java programming interesting.
In C, a struct models what a thing has/is (i.e., the data, also called the characteristics), but not what it does (its behavior, represented by functions).
The functions are outside and separate from structs.
In C++, the characteristics and behavior are integrated into a single structure, called object.
The data type of an object is the class of the object
The packaging of the data and the functions into a class type is called data encapsulation.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
An operating system (OS) is a software program that manages the resources of a computer system and provides a platform for running applications. Its primary functions include resource management, process management, memory management, file system management, and user interface. There are many different types of operating systems, such as desktop operating systems like Windows and macOS, server operating systems like Linux and Windows Server, and embedded operating systems like those used in mobile phones and other small devices. The choice of operating system depends on the type of device, the intended use, and other factors.
What is a Database?
Database creation steps
Benefits of using Database
Types of Table Relationships
What is a Database model
Database Management System
Users of Database
MS Access
Program, Language, & Programming Language
Object Oriented Programming vs Procedure Oriented Programming
About C
Why still Learn C?
Basic Terms
C Stuff
C Syntax
C Program
Algorithm
What is an algorithm?
How are mathematical statements and algorithms related?
What do algorithms have to do with computers?
Pseudo Code
What is pseudocode?
Writing pseudocode
Pseudo Code vs Algorithm
Components of Data Communication
Characteristics of Data Transmission
Communication Media
Communication Speed
Communication Hardware
Communication Software
OSI Model
Introduction
Syed Zaid Irshad
Rules (that You have to Follow)
Book Introduction
10 Chapters
Theoretical Chapters are 6
Practical Chapters are 4
Chapter 1: Basic Concept of Information Technology
Introduction of Computer
Definition
Characteristics
Parts of Computer
Input
Output
Memory
Primary Storage
Secondary Storage
Ports
Language Translator
Compiler
Interpreter
Generations of Programming Language
Ages of Computers
Generations of Computer
Classification of Computers
Chapter 2: Information Networks
Types of Network
LAN
WAN
MAN
GAN
Topologies
Star
Ring
Bus
Hybrid
File Transfer Protocol
World Wide Web
Chapter 3: Data Communication
Standards
Transmission
Simples
Half Duplex
Full Duplex
Media
Twisted Pair Cable
Coaxial Cable
Fiber Optic Cable
Microwave Transmission
Satellite Transmission
Open Systems Interconnection model (OSI model)
Chapter 4: Applications and Use of Computers
Difference Between Application and Use
Impacts of Computers
Chapter 5: Computer Architecture
Address of Memory Locations
Instruction Format
Fetch and Execute
Chapter 6: Security, Copyright and The Law
Computer Crime
Computer Viruses
Computer Privacy
Software Piracy and Law
Chapter 7: Operating System
User Interface
Graphical User Interface
Operating Systems
Chapter 8: Word Processing
Introduction to MS Word
Creating
Editing
Formatting
Printing
Chapter 9: Spreadsheet
Introduction to MS Excel
Creating
Editing
Formatting
Printing
Formulae
Project
Chapter 10: Internet Browsing and Using E-mail
Create Email ID
Send Mail
Download File
Upload File
Study Plan
Every Tuesday we perform Practical
Every Friday Half of the Lecture will be used as question answer session
Rest of the days are for Theoretical Stuff
Make WhatsApp Group for class where we can share stuff related to the Subject
1st Year Computer Science Book
Sindh Text Book Board Introduction
Introduction
Syed Zaid Irshad
Rules (that You have to Follow)
Book Introduction
10 Chapters
Theoretical Chapters are 6
Practical Chapters are 4
Chapter 1: Basic Concept of Information Technology
Introduction of Computer
Definition
Characteristics
Parts of Computer
Input
Output
Memory
Primary Storage
Secondary Storage
Ports
Language Translator
Compiler
Interpreter
Generations of Programming Language
Ages of Computers
Generations of Computer
Classification of Computers
Chapter 2: Information Networks
Types of Network
LAN
WAN
MAN
GAN
Topologies
Star
Ring
Bus
Hybrid
File Transfer Protocol
World Wide Web
Chapter 3: Data Communication
Standards
Transmission
Simples
Half Duplex
Full Duplex
Media
Twisted Pair Cable
Coaxial Cable
Fiber Optic Cable
Microwave Transmission
Satellite Transmission
Open Systems Interconnection model (OSI model)
Chapter 4: Applications and Use of Computers
Difference Between Application and Use
Impacts of Computers
Chapter 5: Computer Architecture
Address of Memory Locations
Instruction Format
Fetch and Execute
Chapter 6: Security, Copyright and The Law
Computer Crime
Computer Viruses
Computer Privacy
Software Piracy and Law
Chapter 7: Operating System
User Interface
Graphical User Interface
Operating Systems
Chapter 8: Word Processing
Introduction to MS Word
Creating
Editing
Formatting
Printing
Chapter 9: Spreadsheet
Introduction to MS Excel
Creating
Editing
Formatting
Printing
Formulae
Project
Chapter 10: Internet Browsing and Using E-mail
Create Email ID
Send Mail
Download File
Upload File
Study Plan
Every Tuesday we perform Practical
Every Friday Half of the Lecture will be used as question answer session
Rest of the days are for Theoretical Stuff
Make WhatsApp Group for class where we can share stuff related to the Subject
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
Understanding Inductive Bias in Machine LearningSUTEJAS
This presentation explores the concept of inductive bias in machine learning. It explains how algorithms come with built-in assumptions and preferences that guide the learning process. You'll learn about the different types of inductive bias and how they can impact the performance and generalizability of machine learning models.
The presentation also covers the positive and negative aspects of inductive bias, along with strategies for mitigating potential drawbacks. We'll explore examples of how bias manifests in algorithms like neural networks and decision trees.
By understanding inductive bias, you can gain valuable insights into how machine learning models work and make informed decisions when building and deploying them.
Water billing management system project report.pdfKamal Acharya
Our project entitled “Water Billing Management System” aims is to generate Water bill with all the charges and penalty. Manual system that is employed is extremely laborious and quite inadequate. It only makes the process more difficult and hard.
The aim of our project is to develop a system that is meant to partially computerize the work performed in the Water Board like generating monthly Water bill, record of consuming unit of water, store record of the customer and previous unpaid record.
We used HTML/PHP as front end and MYSQL as back end for developing our project. HTML is primarily a visual design environment. We can create a android application by designing the form and that make up the user interface. Adding android application code to the form and the objects such as buttons and text boxes on them and adding any required support code in additional modular.
MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software. It is a stable ,reliable and the powerful solution with the advanced features and advantages which are as follows: Data Security.MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
Forklift Classes Overview by Intella PartsIntella Parts
Discover the different forklift classes and their specific applications. Learn how to choose the right forklift for your needs to ensure safety, efficiency, and compliance in your operations.
For more technical information, visit our website https://intellaparts.com
2. 2
Why Multiple Files
• Re-use
• Better data abstraction (data hiding)
• More manageability of large programs
3. 3
The Multiple-File Approach
• Have each major class as a separate program
• Re-use: The class can then be used by other programs using the #include
macro instead of the copy-&-paste approach
• Put the class/function declarations in a header (.h) file, and the
class/function implementations in another (.c or .cpp) file. This
achieves data hiding.
4. 4
Example
class Stack {
public:
typedef int dtype;
Stack(int cap=100);
int getCapacity();
void push(dtype b);
dtype pop();
dtype peek();
bool isEmpty();
private:
dtype *dataptr;
int top;
int capacity;
};
#include "Stack.h"
Stack::Stack(int cap){
top=0;
capacity = (cap>0)?cap:100;
dataptr = new int[capacity];
};
int Stack::getCapacity( ) {
return capacity;
};
int Stack::dtype Stack::pop(){
assert(!isEmpty());
return dataptr[--top];
};
// the implementation of
// the remaining methods
........
#include <cstdlib>
#include <iostream>
#include "Stack.h”
using namespace std;
// local stuff, if any
int main(int argc,
char *argv[]){
………
}
Stack.h file: Stack.cpp file: Project1.cpp file:
5. 5
What should Go into a .h File
• Only declarations (i.e., info to the compiler)
• Nothing that requires storage
• Reason:
• a header file gets included in several files of a project;
• if storage for a variable (or for a code) is allocated multiple times, you get a
multiple-definition compilation error
• Advanced: One exception to this rule is static data (data local to a
file), because the linker does not allocate multiple instances to static
data.
6. 6
Redeclarations Issues
• An X.h file can have: #include “Y.h”
• Consider this scenario:
• The X.h file has:
#include “Y.h”
#include “Z.h”
• The Y.h file has: #include “Z.h”
• This means: the declarations in Z.h are included twice
in X.h. The second declarations are called
redeclarations
• Class redeclarations are not allowed.
• So, we have a problem
7. 7
Redeclarations Issue Solution
• Inside each Z.h file, do:
• Add to at the start of the file (right after all the #includes) the next two lines:
#ifndef Z_H_ // Not that Z is the name of .h file
#define Z_H_
• Add the following line at the very end of Z.h (on a separate line):
#enddef
8. 8
Class Inheritance in C++
• Inheritance allows us to create new classes which are derived from
older classes
• The derived classes are
called subclasses or simply
derived classes
• The older classes are superclasses
or parent classes or base classes
• A derived class automatically includes some of its parent's members,
and can have additional ones.
base
subclass1 subclass2
Notation:
9. 9
Conceptual Examples of Hierarchical
Classes
Animal
PersonReptile Bird
Man Woman
Person
StudentLawyer Engineer
Grad UG
MotherFather
10. 10
Syntax for Inheritance
class derivedClass : public baseClass {
private :
// Declarations of additional members, if needed.
public:
// Declarations of additional members, if needed.
protected:
// Declarations of additional members, if needed.
}
The derived class inherits from the base class: all public members,
all protected members (see later), and the default constructor
The additional members defined can have the same name (and type) as
those of the base class (as when some base members are to be redefined)
11. 11
“Protected” Access
• We have seen two access modes in C++ classes: public and private
• Public members are directly accessible by users of the class
• Private members are NOT directly accessible by users of the class, not even by
inheritors
• There is a 3rd access mode: protected
• Protected members are directly accessible by derived classes but not by other
users
12. 12
Example of Inherited Classes
class Shape {
protected:
int width, height;
public:
void setDims (int a, int b){
width=a; height=b;}
};
class Rectangle: public Shape {
public:
int area ( ) {
return (width * height);
}
};
class Triangle: public Shape {
public:
int area ( ) {
return (width * height/2);
}
};
class Square: public Rectangle {
public:
void setDims (int a){
width=a; height=a;}
};
13. 13
Another Example of Inherited Classes
(A char stack inherited from string)
class CharStack: public string{
public:
void push(char b){
string str; str += b;
insert(0,str);};
char peek( ){return at(0);};
char pop( ){
char a=at(0); erase(0,1);
return a; };
// size( ) and empty( ) are the
// same in string, so are
// inherited as is.
}
Observations:
• We have no idea how
the string class is
implemented, and we
don’t care
• CharStack inherited
from string all the latter’s
public methods, including
size( ) and empty( )
• We implemented push( ),
pop( ) and peek( ) using
the public methods of
the string class
14. 14
More on Inheritance Syntax
class derivedClass : protected baseClass { …};
// Effect: all public members inherited from baseClass are
// now protected members of derivedClass
class derivedClass : private baseClass { …};
// Effect: all public and protected members inherited from
// baseClass are now private members of derivedClass
Multiple inheritance A class can inherit several classes
at once:
class derivedClass:public baseClass1,public baseClass2{ …};
Remark: Not recommended
15. 15
Templates
• We saw function templates early on
• Templates allow us to turn the type of data into a
parameter that can be changed at will
• For example, we defined stacks/queues/trees of
ints
• If we want a stack/queues/trees of floats, we have to
cut and paste, and change the data type from int to
float
• We reduced this effort by using: typedef int datatype;
• That is still inconvenient, time-consuming, and error
prone
• With templates, we do not need to cut+paste+change
16. 16
Function Templates (Reminder )
• Syntax for declaring a function template:
template<class type> function_declaration;
-Or-
template<typename type> function_declaration;
Example of a Function Template Declaration:
// Returns the minimum of array x[ ]. The data
// type of x[ ] is arbitrary & customizable
template<typename T> T min(T x[], int length){
T m = x[0]; // M is the minimum so far
for (int i=1;i<n;i++)
if (x[i]<m) m=x[i];
return m;
}
Example of Use:
int x[]=
{11, 13, 5, 7, 4, 10};
double y[]=
{4.5, 7.13, 17};
int minx =
min<int>(x,6);
double miny=
min<double>(y,3);
17. 17
Templates with More than One Generic Type
• Templates can have several generic types
• Syntax for their declaration:
• class can be replaced by typename.template<class type1,class type2> funct_decl;
18. 18
Class Templates
• Much as function templates allow argument types
to be parameterized, class templates allow us to
parameterize the types of:
• member variables
• arguments of member functions & constructors
• return values of member functions
• The syntax is similar but somewhat more
cumbersome
19. 19
Class Templates Syntax
• For class template declaration:
• For the implementation of the methods outside the class, the syntax
is:
• For the implementation of the constructors outside the class, the
syntax is:
template<class T> class_declaration;
template<class T> return_type className<T>::methodName(parameter-list){
……}
template<class T> className<T>:: className(parameter-list){……}
20. 20
template <class T> class stack {
private :
T *dataptr;
int top;
int capacity;
public:
stack(int cap=100);
int getCapacity() {return capacity;}
void push(T b);
T pop() {assert(top>0); return dataptr[--top];}
bool isEmpty() {return top==0;}
};
Stack as a Class Template
22. 22
A Complete Program Using a Stack Template
#include <cstdlib>
#include <iostream>
using namespace std;
// template stack definition goes here
int main(int argc, char *argv[]){
stack<int> intS(5); // a stack of integers
cout<<"intS capacity after construction = "<<intS.getCapacity()<<endl;
int x[]={2,3,7,8,-10,14,5};
for (int i=0;i<7;i++)
intS.push(x[i]);
cout<<"intS capacity after pushing 7 elements="<< intS.getCapacity();
cout<<“nEmptying intS: ";
while (!intS.isEmpty())
cout<<intS.pop()<<"; ";
cout<<endl;
23. 23
stack<char *> stringS(5); // a stack of strings
stringS.push("hi");
stringS.push("there");
cout<<"Emptying stringS: ";
while (!stringS.isEmpty())
cout<<stringS.pop()<<"; ";
cout<<endl;
double y[]={3.14,9.8,1.42,12};
stack<double> doubleS(y,4); // a stack of doubles
cout<<"doubleS capacity="<<doubleS.getCapacity()<<endl;
cout<<"Emptying doubleS: ";
while (!doubleS.isEmpty())
cout<<doubleS.pop()<<"; ";
cout<<endl;
}
24. 24
C++ Standard Templates Library (STL)
• C++ comes
with a library
that supports
most of the
data structures
(i.e., classes)
we covered in
this semester
Class What to Include
stack #include <stack>
queue #include <queue>
list #include <list>
heap #include <heap>
set #include <set>
vector #include <vector>
25. 25
Some Operations of STL Classes
stack queue
// constructor
stack<T> s;
//T is any built-in or user-defined type
void push (T a)
void pop( ); // deletes top element.
T top( ); // like peek().
int size( ); // returns # elements in s
bool empty(); // // true if s is empty
// constructor
queue<T> q;
T front( ); //returns front value
T back( ); //returns back value
void push (T a); // enqueue
void pop( ); //dequeue
int size( ); // returns # elements in q
bool empty(); // true if q is empty