EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics and Computer Science
|
|
- Merry Baldwin
- 6 years ago
- Views:
Transcription
1 EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics and Computer Science Written examination Homologation C++ and Computer Organization (2DMW00) Part I: C++ - on Tuesday, November 1st 2016, 9:00h-12:00h. Hand-in the answers to this 1st part of the examination on separate sheets of paper, and make sure to put your name and identification number on the paper. Read all the questions carefully. Select one of more answers, when needed, marking the selected answers. Points for each question are indicated between parentheses and sum up to 10 points. No laptop or smart devices are allowed to be used. Good luck! 1. (0.25) What is the output of the following program? int main() { int n = 210, m = 110; funcone(n, m); cout << n = << n <<, m = << m << endl; return 0; void funcone(int n, int &m) { n = 240; m = 125 a. n = 240, m = 110 b. n = 240, m = 125 c. n = 210, m = 110 d. n =210, m = (0.25) Which of the following functions will increment an integer passed as argument to the functions? void inc1(int a) { a++; void inc2(int *p) { p++; void inc3(int *p) { (*p)++; void inc4(int &i) { i++; a. Function inc1 and inc4 b. Functions inc2 and inc1
2 c. Functions inc3 and inc1 d. Functions inc3 and inc4 3. (0.25) Which constructor function is designed to copy objects of the same class type? a. Create constructor b. Object constructor c. Dynamic constructor d. Copy constructor 4. (0.25) Which of the following function declaration is/are incorrect? a. int sum(int a, int b = 2, int c = 3); b. int sum(int a = 5, int b); c. int sum(int a = 0, int b, int c = 3); d. Both B and C are incorrect. e. All are correct. 5. (0.25) A protected member of the class is accessible in a. Only same class b. Same class and derived class c. Outside the class d. None of the above. 6. (0.25) What does a class hierarchy depict? a. It shows the relationships between the classes in the form of an organization chart. b. It describes "has a" relationships. c. It describes "kind of" relationships. d. It shows the same relationship as a family tree. 7. (0.25) Choose the pure virtual function definition from the following: a. virtual void f() = 0 { b. void virtual f() = 0 { c. virtual void f() { = 0; d. None of the above.
3 8. (0.25) Choose the respective delete operator usage for the expression ptr=new int[100]. a. delete ptr; b. delete ptr[]; c. delete[] ptr; d. []delete ptr; 9. (6.0) Create a class Calculator which contains only a single component of type double. The class implements the four arithmetic operations: addition, subtraction, multiplication and division. The class can be used, by example, in this way: Calculator a(20), b(30), c, d, e, f; c = a + b; d = a b; e = a * b; f = b / a; cout << "c = " << c; The structure of the class looks like : private: double a; // The constructor // Overloaded the + operator // Overloaded the - operator // Overloaded the * operator // Overloaded the / operator // Overloaded the input >> operator // Overloaded the output << operator ; Implement or overload the methods of the class: a. the constructor b. the + operator c. the - operator d. the * operator e. the / operator f. the input >> operator g. the output << operator and write a test program to test the class methods.
4 Solution // calculator.h file // define the methods // Constructor Calculator(double a = 0) : a(a) { // overload the operators Calculator operator+(const Calculator& c) { return Calculator(a + c.a); Calculator operator-(const Calculator& c) { return Calculator(a - c.a); Calculator operator*(const Calculator& c) { return Calculator(a * c.a); Calculator operator/(const Calculator& c) { if (c.a!= 0.0) return Calculator(a / c.a); else cout << "Division by zero\n"; return Calculator(1); // define the output stream operator friend ostream& operator<<(ostream& output, const Calculator& c) { output << "Calculator a = " << c.a << endl; return output; // define the input stream operator friend istream& operator>>(istream& input, Calculator& c) { cout << "Typein the value of a: "; input >> c.a; return input; // atrribute double a; ; // end calculator.h // mainprogram for testing #include "calculator.h" int main() { Calculator c1, c2(10), c3(100); cout << c1 << c2 << endl; cout << c3 + c2 << endl; cout << c3 - c2 << endl; cout << c3 * c2 << endl; cout << c3 / c2 << endl; // end mainprogram.cpp
5 10. (2.0) Create a class Calculator which contains only a single component of type double * (pointer to double). The class can be used, for example, in this way: Calculator a(20), b(30), c; c = a + b; count << "c = " << c; The structure of the class looks like: private: double *a; // The constructor // The copy constructor // The destructor // The assignment = operator // Overloaded the + operator ; Implement or overload only the following methods: a. the constructor b. the destructor c. the + operator Note: You can get bonus points (0.5 points per operator) if you can implement more operators (-, *, /, =) or the copy constructor for the class defined in question 10! Solution // calculator.h file // define the methods // Constructor Calculator(double a = 0) { // allocate memory
6 this->a = new double; *(this->a) = a; // copy constructor Calculator(const Calculator& c) { // allocate memory this->a = new double; // copy data *(this->a) = *(c.a); // define the destructor ~Calculator() { //de-allocate the data delete a; // overload the operators Calculator operator+(const Calculator& c) { return Calculator(*a + *(c.a)); Calculator operator-(const Calculator& c) { return Calculator(*a - *(c.a)); Calculator operator*(const Calculator& c) { return Calculator(*a * *(c.a)); Calculator operator/(const Calculator& c) { if (*(c.a)!= 0.0) return Calculator(*a / *(c.a)); else cout << "Division by zero\n"; return Calculator(1); // the assignment operator Calculator& operator=(const Calculator& c) { if (this!= &c) {// test the situation c = c // *a = *(c.a); return *this; // for c1=c2=c3...=c3 case // define the output stream operator friend ostream& operator<<(ostream& output, const Calculator& c) { output << "Calculator a = " << *(c.a) << endl; return output; // define the input stream operator friend istream& operator >> (istream& input, Calculator& c) { cout << "Typein the value of a: "; input >> *(c.a); return input; // attribute double *a; ; // end calculator.h file // mainprogram for testing #include "calculator.h" int main()
7 { Calculator c1, c2(10), c3(100); cout << c1 << c2 << endl; cout << c3 + c2 << endl; cout << c3 - c2 << endl; cout << c3 * c2 << endl; cout << c3 / c2 << endl; // end mainprogram.cpp
IS0020 Program Design and Software Tools Midterm, Fall, 2004
IS0020 Program Design and Software Tools Midterm, Fall, 2004 Name: Instruction There are two parts in this test. The first part contains 22 questions worth 40 points you need to get 20 right to get the
More informationVectors of Pointers to Objects. Vectors of Objects. Vectors of unique ptrs C++11. Arrays of Objects
Vectors of Objects As we have mentioned earlier, you should almost always use vectors instead of arrays. If you need to keep track of persons (objects of class Person), you must decide what to store in
More informationKOM3191 Object Oriented Programming Dr Muharrem Mercimek OPERATOR OVERLOADING. KOM3191 Object-Oriented Programming
KOM3191 Object Oriented Programming Dr Muharrem Mercimek 1 OPERATOR OVERLOADING KOM3191 Object-Oriented Programming KOM3191 Object Oriented Programming Dr Muharrem Mercimek 2 Dynamic Memory Management
More informationReview: C++ Basic Concepts. Dr. Yingwu Zhu
Review: C++ Basic Concepts Dr. Yingwu Zhu Outline C++ class declaration Constructor Overloading functions Overloading operators Destructor Redundant declaration A Real-World Example Question #1: How to
More informationMore Advanced Class Concepts
More Advanced Class Concepts Operator overloading Inheritance Templates PH (RH) (Roger.Henriksson@cs.lth.se) C++ Programming 2016/17 146 / 281 Operator Overloading In most programming languages some operators
More informationIntermediate Programming & Design (C++) Classes in C++
Classes in C++ A class is a data type similar to a C structure. It includes various local data (called data members) together with constructors, destructors and member functions. All of them are called
More informationReview. What is const member data? By what mechanism is const enforced? How do we initialize it? How do we initialize it?
Review Describe pass-by-value and pass-by-reference Why do we use pass-by-reference? What does the term calling object refer to? What is a const member function? What is a const object? How do we initialize
More informationHomework #3 CS2255 Fall 2012
Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation
More informationCh. 12: Operator Overloading
Ch. 12: Operator Overloading Operator overloading is just syntactic sugar, i.e. another way to make a function call: shift_left(42, 3); 42
More informationUse the dot operator to access a member of a specific object.
Lab 16 Class A class is a data type that can contain several parts, which are called members. There are two types of members, data member and functions. An object is an instance of a class, and each object
More informationOverloaded Operators, Functions, and Students
, Functions, and Students Division of Mathematics and Computer Science Maryville College Outline Overloading Symbols 1 Overloading Symbols 2 3 Symbol Overloading Overloading Symbols A symbol is overloaded
More informationOperator overloading. Instructor: Bakhyt Bakiyev
Operator overloading Instructor: Bakhyt Bakiyev content Operator overloading Operator Overloading CONCEPT: C++ allows you to redefine how standard operators work when used with class objects. Approaches
More informationA <Basic> C++ Course
A C++ Course 5 Constructors / destructors operator overloading Julien Deantoni adapted from Jean-Paul Rigault courses This Week A little reminder Constructor / destructor Operator overloading Programmation
More informationA <Basic> C++ Course
A C++ Course 5 Constructors / destructors operator overloading Julien DeAntoni adapted from Jean-Paul Rigault courses 1 2 This Week A little reminder Constructor / destructor Operator overloading
More informationOverloading Operators in C++
Overloading Operators in C++ C++ allows the programmer to redefine the function of most built-in operators on a class-by-class basis the operator keyword is used to declare a function that specifies what
More informationCISC 2200 Data Structure Fall, C++ Review:3/3. 1 From last lecture:
CISC 2200 Data Structure Fall, 2016 C++ Review:3/3 1 From last lecture: pointer type and pointer variable (stores memory addresses of a variable (of any type, local or global, automatic/static/dynamic)
More informationObject oriented programming
Exercises 12 Version 1.0, 9 May, 2017 Table of Contents 1. Virtual destructor and example problems...................................... 1 1.1. Virtual destructor.......................................................
More informationCome and join us at WebLyceum
Come and join us at WebLyceum For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc Go to http://www.weblyceum.com and click Register In Case of any Problem Contact Administrators Rana Muhammad
More informationCircle all of the following which would make sense as the function prototype.
Student ID: Lab Section: This test is closed book, closed notes. Points for each question are shown inside [ ] brackets at the beginning of each question. You should assume that, for all quoted program
More information3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.
3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.
More informationObject-Oriented Principles and Practice / C++
Object-Oriented Principles and Practice / C++ Alice E. Fischer September 26, 2016 OOPP / C++ Lecture 4... 1/33 Global vs. Class Static Parameters Move Semantics OOPP / C++ Lecture 4... 2/33 Global Functions
More informationDue Date: See Blackboard
Source File: ~/2315/45/lab45.(C CPP cpp c++ cc cxx cp) Input: under control of main function Output: under control of main function Value: 4 Integer data is usually represented in a single word on a computer.
More informationIntermediate Programming, Spring 2017*
600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general
More informationCh 8. Operator Overloading, Friends, and References
2014-1 Ch 8. Operator Overloading, Friends, and References May 28, 2014 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel
More informationSuppose we find the following function in a file: int Abc::xyz(int z) { return 2 * z + 1; }
Multiple choice questions, 2 point each: 1. What output is produced by the following program? #include int f (int a, int &b) a = b + 1; b = 2 * b; return a + b; int main( ) int x=1, y=2, z=3;
More informationpointers + memory double x; string a; int x; main overhead int y; main overhead
pointers + memory computer have memory to store data. every program gets a piece of it to use as we create and use more variables, more space is allocated to a program memory int x; double x; string a;
More informationAbstract Data Types (ADTs) 1. Legal Values. Client Code for Rational ADT. ADT Design. CS 247: Software Engineering Principles
Abstract Data Types (ADTs) CS 247: Software Engineering Principles ADT Design An abstract data type (ADT) is a user-defined type that bundles together: the range of values that variables of that type can
More informationCS201- Introduction to Programming Current Quizzes
CS201- Introduction to Programming Current Quizzes Q.1 char name [] = Hello World ; In the above statement, a memory of characters will be allocated 13 11 12 (Ans) Q.2 A function is a block of statements
More informationFORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):
FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): 1. If a function has default arguments, they can be located anywhere
More informationPolymorphism. Zimmer CSCI 330
Polymorphism Polymorphism - is the property of OOP that allows the run-time binding of a function's name to the code that implements the function. (Run-time binding to the starting address of the code.)
More informationProgram construction in C++ for Scientific Computing
1 (26) School of Engineering Sciences Program construction in C++ for Scientific Computing 2 (26) Outline 1 2 3 4 5 6 3 (26) Our Point class is a model for the vector space R 2. In this space, operations
More informationCS 247: Software Engineering Principles. ADT Design
CS 247: Software Engineering Principles ADT Design Readings: Eckel, Vol. 1 Ch. 7 Function Overloading & Default Arguments Ch. 12 Operator Overloading U Waterloo CS247 (Spring 2017) p.1/17 Abstract Data
More informationConcepts (this lecture) CSC 143. Classes with Dynamically Allocated Data. List of ints w/dups (cont.) Example: List of ints with dups.
CSC 143 Classes with Dynamically Allocated Data Concepts (this lecture) Constructors and destructors for dynamic data The this pointer Deep versus shallow copy Defining assignment (operator=) Copy constructor
More informationProgramming, numerics and optimization
Programming, numerics and optimization Lecture A-4: Object-oriented programming Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428
More informationOverloading & Polymorphism
Overloading & Polymorphism Overloading is considered ad-hoc polymorphism. 1 Can define new meanings (functions) of operators for specific types. Compiler recognizes which implementation to use by signature
More informationDo not write in this area TOTAL. Maximum possible points: 75
Name: Student ID: Instructor: Borja Sotomayor Do not write in this area 1 2 3 4 5 6 7 TOTAL Maximum possible points: 75 This homework assignment is divided into two parts: one related to the fundamental
More informationCS 162, Lecture 25: Exam II Review. 30 May 2018
CS 162, Lecture 25: Exam II Review 30 May 2018 True or False Pointers to a base class may be assigned the address of a derived class object. In C++ polymorphism is very difficult to achieve unless you
More informationIntroduction to Computer Science Midterm 3 Fall, Points
Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do
More informationReference Parameters A reference parameter is an alias for its corresponding argument in the function call. Use the ampersand (&) to indicate that
Reference Parameters There are two ways to pass arguments to functions: pass-by-value and pass-by-reference. pass-by-value A copy of the argument s value is made and passed to the called function. Changes
More informationSFU CMPT Topic: Class Templates
SFU CMPT-212 2008-1 1 Topic: Class Templates SFU CMPT-212 2008-1 Topic: Class Templates Ján Maňuch E-mail: jmanuch@sfu.ca Monday 3 rd March, 2008 SFU CMPT-212 2008-1 2 Topic: Class Templates Class templates
More informationCS201 Latest Solved MCQs
Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability
More information14.1. Chapter 14: static member variable. Instance and Static Members 8/23/2014. Instance and Static Members
Chapter 14: More About Classes 14.1 Instance and Static Members Instance and Static Members instance variable: a member variable in a class. Each object has its own copy. static variable: one variable
More informationDue Date: See Blackboard
Source File: ~/2315/11/lab11.(C CPP cpp c++ cc cxx cp) Input: Under control of main function Output: Under control of main function Value: 1 The purpose of this assignment is to become more familiar with
More informationShahram Rahatlou. Computing Methods in Physics. Overloading Operators friend functions static data and methods
Overloading Operators friend functions static data and methods Shahram Rahatlou Computing Methods in Physics http://www.roma1.infn.it/people/rahatlou/cmp/ Anno Accademico 2018/19 Today s Lecture Overloading
More informationCPSC 427: Object-Oriented Programming
CPSC 427: Object-Oriented Programming Michael J. Fischer Lecture 7 September 21, 2016 CPSC 427, Lecture 7 1/21 Brackets Example (continued) Storage Management CPSC 427, Lecture 7 2/21 Brackets Example
More informationCSS 342 Data Structures, Algorithms, and Discrete Mathematics I. Lecture 2. Yusuf Pisan
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I Lecture 2 Yusuf Pisan Compiled helloworld yet? Overview C++ fundamentals Assignment-1 CSS Linux Cluster - submitting assignment Call by Value,
More informationC++ 8. Constructors and Destructors
8. Constructors and Destructors C++ 1. When an instance of a class comes into scope, the function that executed is. a) Destructors b) Constructors c) Inline d) Friend 2. When a class object goes out of
More informationObject oriented programming
Exercises 6 Version 1.0, 21 March, 2017 Table of Contents 1. Operators overloading....................................................... 1 1.1. Example 1..............................................................
More informationOutline. User-dened types Categories. Constructors. Constructors. 4. Classes. Concrete classes. Default constructor. Default constructor
Outline EDAF50 C++ Programming 4. Classes Sven Gestegård Robertz Computer Science, LTH 2018 1 Classes the pointer this const for objects and members Copying objects friend inline 4. Classes 2/1 User-dened
More information11.2. Overloading Operators
11.2 Overloading Operators Overloading Operators In the Money class, function add was used to add two objects of type Money In this section we see how to use the '+' operator to make the following code
More informationName: Username: I. 10. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015
CMSC 202 Section 06 Fall 2015 Computer Science II Midterm Exam II Name: Username: Score Max Section: (check one) 07 - Sushant Athley, Tuesday 11:30am 08 - Aishwarya Bhide, Thursday 11:30am 09 - Phanindra
More informationLecture 3 ADT and C++ Classes (II)
CSC212 Data Structure - Section FG Lecture 3 ADT and C++ Classes (II) Instructor: Feng HU Department of Computer Science City College of New York @ Feng HU, 2016 1 Outline A Review of C++ Classes (Lecture
More informationQuiz Start Time: 09:34 PM Time Left 82 sec(s)
Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability
More informationPOINTERS - Pointer is a variable that holds a memory address of another variable of same type. - It supports dynamic allocation routines. - It can improve the efficiency of certain routines. C++ Memory
More informationSoftware Engineering Concepts: Invariants Silently Written & Called Functions Simple Class Example
Software Engineering Concepts: Invariants Silently Written & Called Functions Simple Class Example CS 311 Data Structures and Algorithms Lecture Slides Friday, September 11, 2009 continued Glenn G. Chappell
More informationIntroduction to Programming using C++
Introduction to Programming using C++ Lecture One: Getting Started Carl Gwilliam gwilliam@hep.ph.liv.ac.uk http://hep.ph.liv.ac.uk/~gwilliam/cppcourse Course Prerequisites What you should already know
More informationSet Implementation Version 1
Introduction to System Programming 234122 Set Implementation Version 1 Masha Nikolski, CS Department, Technion 1 // Version 1.0 2 // Header file for set class. 3 // In this implementation set is a container
More informationKEY printed. Do not start the test until instructed to do so! CS 2704 Object-Oriented Software Design and Construction Test 1.
VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Instructions: Print your name in the space provided below. Answer each question in the space provided. If you want partial credit, justify
More informationOperator Overloading in C++ Systems Programming
Operator Overloading in C++ Systems Programming Operator Overloading Fundamentals of Operator Overloading Restrictions on Operator Overloading Operator Functions as Class Members vs. Global Functions Overloading
More informationpointers & references
pointers & references 1-22-2013 Inline Functions References & Pointers Arrays & Vectors HW#1 posted due: today Quiz Thursday, 1/24 // point.h #ifndef POINT_H_ #define POINT_H_ #include using
More informationSearching Algorithms. Chapter 11
Data Structures Dr Ahmed Rafat Abas Computer Science Dept, Faculty of Computer and Information, Zagazig University arabas@zu.edu.eg http://www.arsaliem.faculty.zu.edu.eg/ Searching Algorithms Chapter 11
More informationIntro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.
Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype
More informationInheritance and Polymorphism
Inheritance and Polymorphism 1 Inheritance extending a clock to an alarm clock deriving a class 2 Polymorphism virtual functions and polymorphism abstract classes MCS 360 Lecture 8 Introduction to Data
More informationEL2310 Scientific Programming
(pronobis@kth.se) Overview Overview Wrap Up Introduction to Object Oriented Paradigm More on and Members Operator Overloading Last time Intro to C++ Differences between C and C++ Intro to OOP Today Object
More informationCS11 Advanced C++ Spring 2018 Lecture 1
CS11 Advanced C++ Spring 2018 Lecture 1 Welcome to CS11 Advanced C++! A deeper dive into C++ programming language topics Prerequisites: CS11 Intro C++ track is strongly recommended (obvious) You should
More informationMidterm Review. PIC 10B Spring 2018
Midterm Review PIC 10B Spring 2018 Q1 What is size t and when should it be used? A1 size t is an unsigned integer type used for indexing containers and holding the size of a container. It is guarenteed
More informationBinary Tree Implementation
Binary Tree Implementation Lecture 31 Sections 12.2-12.3 Robb T. Koether Hampden-Sydney College Mon, Apr 5, 2010 Robb T. Koether (Hampden-Sydney College) Binary Tree Implementation Mon, Apr 5, 2010 1 /
More informationDocumentation. Programming / Documentation Slide 42
Documentation http://www.math.upb.de/~robsy/lehre/programmierkurs2008/ Programming / Documentation Slide 42 Memory Management (I) There are several types of memory which a program can access: Stack Every
More informationCS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE
CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE PART A UNIT I 1. Differentiate object oriented programming from procedure oriented programming. 2. Define abstraction and encapsulation. 3. Differentiate
More informationLecture 2. Binary Trees & Implementations. Yusuf Pisan
CSS 343 Data Structures, Algorithms, and Discrete Math II Lecture 2 Binary Trees & Implementations Yusuf Pisan Overview 1. Huffman Coding and Arithmetic Expressions 2. 342 Topics a. Pointers & References
More informationObject-Oriented Design (OOD) and C++
Chapter 2 Object-Oriented Design (OOD) and C++ At a Glance Instructor s Manual Table of Contents Chapter Overview Chapter Objectives Instructor Notes Quick Quizzes Discussion Questions Projects to Assign
More informationCS11 Intro C++ Spring 2018 Lecture 5
CS11 Intro C++ Spring 2018 Lecture 5 C++ Abstractions C++ provides rich capabilities for creating abstractions class Complex { double re, im; public: Complex(double re, double im);... ; Would be nice if
More informationObject Oriented Programming. Solved MCQs - Part 2
Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What
More informationCSC 330 Object Oriented Programming. Operator Overloading Friend Functions & Forms
CSC 330 Object Oriented Programming Operator Overloading Friend Functions & Forms 1 Restrictions on Operator Overloading Most of C++ s operators can be overloaded. Operators that can be overloaded + -
More informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More informationVIRTUAL FUNCTIONS Chapter 10
1 VIRTUAL FUNCTIONS Chapter 10 OBJECTIVES Polymorphism in C++ Pointers to derived classes Important point on inheritance Introduction to virtual functions Virtual destructors More about virtual functions
More informationAssignment of Objects
Copying Objects 1 Assignment of Objects 2 Slides 1. Table of Contents 2. Assignment of Objects 3. Dynamic Content 4. Shallow Copying 5. Deep Copying 6. this Pointer 7. Improved Deep Copy 8. Passing an
More informationModule 1. C++ Classes Exercises
Module 1. C++ Classes Exercises 1. The ZooAnimal class definition below is missing a prototype for the Create function. It should have parameters so that a character string and three integer values (in
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationCollected By Anonymous
CS201- Introduction to Programming Mega Collection for Final Term Only Solved Paper Year Session Paper # 01 2012 Unknown Paper # 02 2011 (session_02) Paper # 03 2011 (session_03) Paper # 04 2010 Unknown
More informationCMPT 135: Midterm Answer Key
CMPT 135, Spring 2017, Surrey Midterm Answer Key Page 1 of 6 CMPT 135: Midterm Answer Key Last name exactly as it appears on your student card First name exactly as it appears on your student card Student
More informationC++ (Non for C Programmer) (BT307) 40 Hours
C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationUniversity of Swaziland Department Of Computer Science Supplementary Examination JULY 2012
University of Swaziland Department Of Computer Science Supplementary Examination JULY 2012 Title ofpaper: Course number: Time Allowed: Cunder Unix CS344 Three (3) hours Instructions: Answer question 1.
More informationProgram template-smart-pointers-again.cc
1 // Illustrate the smart pointer approach using Templates 2 // George F. Riley, Georgia Tech, Spring 2012 3 // This is nearly identical to the earlier handout on smart pointers 4 // but uses a different
More informationCS105 C++ Lecture 7. More on Classes, Inheritance
CS105 C++ Lecture 7 More on Classes, Inheritance " Operator Overloading Global vs Member Functions Difference: member functions already have this as an argument implicitly, global has to take another parameter.
More informationOutline. A C++ Linked Structure Class A C++ Linked List C++ Linked Dynamic Memory Errors In-class work. 1 Chapter 11: C++ Linked Structures
Outline 1 Chapter 11: C++ Linked Structures A ListNode Class To support a Linked List container class LList, a ListNode class is used for the individual nodes. A ListNode object has two attributes: item
More informationRoxana Dumitrescu. C++ in Financial Mathematics
Roxana Dumitrescu C++ in Financial Mathematics What have we learnt? Arrays; relation between arrays and pointers.. Returning arrays from functions Passing arrays to functions Intoduction to classes Plan
More informationModule Operator Overloading and Type Conversion. Table of Contents
1 Module - 33 Operator Overloading and Type Conversion Table of Contents 1. Introduction 2. Operator Overloading 3. this pointer 4. Overloading Unary Operators 5. Overloading Binary Operators 6. Overloading
More informationBasic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable
Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is
More informationSFU CMPT Topic: Has-a Relationship
SFU CMPT-212 2008-1 1 Topic: Has-a Relationship SFU CMPT-212 2008-1 Topic: Has-a Relationship Ján Maňuch E-mail: jmanuch@sfu.ca Friday 22 nd February, 2008 SFU CMPT-212 2008-1 2 Topic: Has-a Relationship
More informationCS250 Final Review Questions
CS250 Final Review Questions The following is a list of review questions that you can use to study for the final. I would first make sure you review all previous exams and make sure you fully understand
More informationStacks and their Applications
Stacks and their Applications Lecture 23 Sections 18.1-18.2 Robb T. Koether Hampden-Sydney College Fri, Mar 16, 2018 Robb T. Koether Hampden-Sydney College) Stacks and their Applications Fri, Mar 16, 2018
More informationCAAM 420 Fall 2012 Lecture 29. Duncan Eddy
CAAM 420 Fall 2012 Lecture 29 Duncan Eddy November 7, 2012 Table of Contents 1 Templating in C++ 3 1.1 Motivation.............................................. 3 1.2 Templating Functions........................................
More informationLecture 23: Pointer Arithmetic
Lecture 23: Pointer Arithmetic Wai L. Khoo Department of Computer Science City College of New York November 29, 2011 Wai L. Khoo (CS@CCNY) Lecture 23 November 29, 2011 1 / 14 Pointer Arithmetic Pointer
More informationC++_ MARKS 40 MIN
C++_16.9.2018 40 MARKS 40 MIN https://tinyurl.com/ya62ayzs 1) Declaration of a pointer more than once may cause A. Error B. Abort C. Trap D. Null 2Whice is not a correct variable type in C++? A. float
More informationUniversity of Illinois at Urbana-Champaign Department of Computer Science. First Examination
University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2014 Tuesday, February 25, 7-10p Name: NetID: Lab Section
More informationCS250 Final Review Questions
CS250 Final Review Questions The following is a list of review questions that you can use to study for the final. I would first make sure that you review all previous exams and make sure you fully understand
More informationCPSC 427: Object-Oriented Programming
CPSC 427: Object-Oriented Programming Michael J. Fischer Lecture 10 October 1, 2018 CPSC 427, Lecture 10, October 1, 2018 1/20 Brackets Example (continued from lecture 8) Stack class Brackets class Main
More informationCHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object
CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,
More information