Limited time offer 20% OFF StudySoup Subscription details

WSU - CSC 2110 - Study Guide - Midterm

Created by: Alyssax2 Elite Notetaker

WSU - CSC 2110 - Study Guide - Midterm

This preview shows pages 1 - 2 of a 4 page document. to view the rest of the content
background image Computer Science Study Guide  Overloading and Templates  Operator overloading : extends definition of an operator to work 
with a user-defined data type.
C++ allows you to extend the definitions of most of the 
operators to work with classes.
Operators such as: 
Relational operators, arithmetic, operators, the insertion 
operator for data output, and the extraction operator for 
data input. 
operations on classes.
Other operators cannot be applied directly to class objects 
by default. 
Examples of overload operators:  - Arithmetic operator /: if both operands of / are integers, the  result is an integer; otherwise, the result is a floating-point 
- This means that the / operator has one definition when both  operands are integers and another when an operand is a 
floating-point number. 
- Which definition is used depends on the data types of the  operand it is used with.  Extraction operator >> and insertion operator <<: - Have been loaded for various data types, such as int, double, string Operator like + and - : 
The results of + and – are different for integers arithmetic, 
floating-point arithmetic, and pointer arithmetic. 
In order to overload an operator, you must write function(s) to 
define what operation the overloaded operator indicates should 
be performed. 
Operator function :  the function that overloads an operator. 
background image - Use reserved word operator as the function name followed  by the operator to be overloaded.  Syntax of an operator function heading : 
returnType operator operatorSymbol ( formal parameter 
- The result of an operation is a value. Therefore, the operator  function is a value- returning function. Operator is a reserved
- To overload an operator for a class:  - - include the statement to declare  the function prototype  to  overload the operator in the class definition.  - =- write the definition of the operator function.  Overloading an operator : some restrictions    you cannot change the precedence of an operator.    The associatvitiy cannot be changed.   For example: the associativity of the arithmetic 
operator addition is from left to right and it cannot be 
  Cannot change the number of parameters an operator 
       Cannot create new operators. Only existing  operators can be overloaded.        The operators that cannot be overloaded are:  .   .*    ::   ?:  sizeof

This is the end of the preview. Please to view the rest of the content
Join more than 18,000+ college students at Wayne State University who use StudySoup to get ahead
School: Wayne State University
Department: Computer Science and Engineering
Course: Computer Science I
Professor: Are
Term: Winter 2018
Tags: Computer and Science
Name: Computer Science Test Help
Description: These notes will cover the chapters we have learned and help you prepare for the test
Uploaded: 03/20/2018
4 Pages 40 Views 32 Unlocks
  • Better Grades Guarantee
  • 24/7 Homework help
  • Notes, Study Guides, Flashcards + More!
Join StudySoup for FREE
Get Full Access to WSU - CSC 2110 - Study Guide - Midterm
Join with Email
Already have an account? Login here
Log in to StudySoup
Get Full Access to WSU - CSC 2110 - Study Guide - Midterm

Forgot password? Reset password here

Reset your password

I don't want to reset my password

Need help? Contact support

Need an Account? Is not associated with an account
Sign up
We're here to help

Having trouble accessing your account? Let us help you, contact support at +1(510) 944-1054 or

Got it, thanks!
Password Reset Request Sent An email has been sent to the email address associated to your account. Follow the link in the email to reset your password. If you're having trouble finding our email please check your spam folder
Got it, thanks!
Already have an Account? Is already in use
Log in
Incorrect Password The password used to log in with this account is incorrect
Try Again

Forgot password? Reset it here