CSS 342: DS&A ; Final Exam
bool operator==(const Object& other) const; - CORRECT ANS Equivalency operator overload signature
bool operator!=(const Object& other) const; - CORRECT ANS Not equivalent operator overload signature
bool operator<=(const Object& other) const; - CORRECT ANS Less than or equal to operator overload
signature
bool operator>=(const Object& other) const; - CORRECT ANS Greater than or equal to operator overload
signature
bool operator<(const Object& other) const; - CORRECT ANS Less than operator overload header
bool operator>(const Object& other) const; - CORRECT ANS Greater than operator overload signature
friend ostream& operator<<(ostream& stream, const Object& rhs); - CORRECT ANS Out stream (output)
operator overload header
friend istream& operator>>(istream& stream, const Object& rhs); - CORRECT ANS In stream (input)
operator overload header
using namespace std; - CORRECT ANS "As", so it makes it so you don't have to use "std::" when doing
istream/ostream operations.
template<class T>
void Method(T parameter); - CORRECT ANS How to templatize methods.
,void Swap(int& a, int& b) {
int temp = a;
a = b;
b = temp;
} - CORRECT ANS Simple swap; int can be switched out for any data type.
int data_; - CORRECT ANS How to format private data members.
#include <iostream> - CORRECT ANS To import the iostream module, this allows input and output.
cout << "Hello World!"; - CORRECT ANS Printing out the terminal, "Hello World!"
string data;
cin >> data; - CORRECT ANS Taking in terminal input to string data variable.
#include <string> - CORRECT ANS Importing the string module, allows for the use of the string data type.
int* number; - CORRECT ANS Pointer to int number; if printed, will print out the memory address of int
number.
#ifndef OBJECT_H_
#define OBJECT_H_
class Object {
...
};
#endif - CORRECT ANS General structure of a object.h file, or a header file for Object.
,Object::Object() {
this->data_ = 0;
...
} - CORRECT ANS General method implementation for a default constructor.
Object::Object(int data) {
this->data_ = data;
...
} - CORRECT ANS General method implementation for a parameterized constructor.
int Object::data() const {
return data_;
} - CORRECT ANS General method implementation for a data member getter.
#include "object.h" - CORRECT ANS To import a header file; this is used for implementation files and the
driver file.
enum Type {kA, kB, kC}; - CORRECT ANS General structure for declaring enumerated types.
Enums - CORRECT ANS They are values used for classification, under the hood, they are integer values
that can be compared. They are a data type that only has specific values.
enum Type {kA, kB, kC};
const string kTypes[3] = {"A", "B", "C"}; - CORRECT ANS For enums, a good practice is to have strings or
values for them, so you can do kTypes[kA], to get "A".
, Object Object::operator*(const Object& rhs) const {
...
return Object();
} - CORRECT ANS General implementation for a multiply operation overload.
Object Object::operator/(const Object& rhs) const {
...
return Object();
} - CORRECT ANS General implementation for a division operation overload.
Object Object::operator-(const Object& rhs) const {
...
return Object();
} - CORRECT ANS General implementation for a subtraction operation overload.
Object Object::operator+(const Object& rhs) const {
...
return Object();
} - CORRECT ANS General implementation for an addition operation overload.
John Von Neumann - CORRECT ANS Who had innovations in Set theory, Geometry, Quantum Mechanics,
Economics, Statistics
John Von Neumann - CORRECT ANS Who founded Game Theory?
John Von Neumann - CORRECT ANS Who made the Monte Carlo Method?
bool operator==(const Object& other) const; - CORRECT ANS Equivalency operator overload signature
bool operator!=(const Object& other) const; - CORRECT ANS Not equivalent operator overload signature
bool operator<=(const Object& other) const; - CORRECT ANS Less than or equal to operator overload
signature
bool operator>=(const Object& other) const; - CORRECT ANS Greater than or equal to operator overload
signature
bool operator<(const Object& other) const; - CORRECT ANS Less than operator overload header
bool operator>(const Object& other) const; - CORRECT ANS Greater than operator overload signature
friend ostream& operator<<(ostream& stream, const Object& rhs); - CORRECT ANS Out stream (output)
operator overload header
friend istream& operator>>(istream& stream, const Object& rhs); - CORRECT ANS In stream (input)
operator overload header
using namespace std; - CORRECT ANS "As", so it makes it so you don't have to use "std::" when doing
istream/ostream operations.
template<class T>
void Method(T parameter); - CORRECT ANS How to templatize methods.
,void Swap(int& a, int& b) {
int temp = a;
a = b;
b = temp;
} - CORRECT ANS Simple swap; int can be switched out for any data type.
int data_; - CORRECT ANS How to format private data members.
#include <iostream> - CORRECT ANS To import the iostream module, this allows input and output.
cout << "Hello World!"; - CORRECT ANS Printing out the terminal, "Hello World!"
string data;
cin >> data; - CORRECT ANS Taking in terminal input to string data variable.
#include <string> - CORRECT ANS Importing the string module, allows for the use of the string data type.
int* number; - CORRECT ANS Pointer to int number; if printed, will print out the memory address of int
number.
#ifndef OBJECT_H_
#define OBJECT_H_
class Object {
...
};
#endif - CORRECT ANS General structure of a object.h file, or a header file for Object.
,Object::Object() {
this->data_ = 0;
...
} - CORRECT ANS General method implementation for a default constructor.
Object::Object(int data) {
this->data_ = data;
...
} - CORRECT ANS General method implementation for a parameterized constructor.
int Object::data() const {
return data_;
} - CORRECT ANS General method implementation for a data member getter.
#include "object.h" - CORRECT ANS To import a header file; this is used for implementation files and the
driver file.
enum Type {kA, kB, kC}; - CORRECT ANS General structure for declaring enumerated types.
Enums - CORRECT ANS They are values used for classification, under the hood, they are integer values
that can be compared. They are a data type that only has specific values.
enum Type {kA, kB, kC};
const string kTypes[3] = {"A", "B", "C"}; - CORRECT ANS For enums, a good practice is to have strings or
values for them, so you can do kTypes[kA], to get "A".
, Object Object::operator*(const Object& rhs) const {
...
return Object();
} - CORRECT ANS General implementation for a multiply operation overload.
Object Object::operator/(const Object& rhs) const {
...
return Object();
} - CORRECT ANS General implementation for a division operation overload.
Object Object::operator-(const Object& rhs) const {
...
return Object();
} - CORRECT ANS General implementation for a subtraction operation overload.
Object Object::operator+(const Object& rhs) const {
...
return Object();
} - CORRECT ANS General implementation for an addition operation overload.
John Von Neumann - CORRECT ANS Who had innovations in Set theory, Geometry, Quantum Mechanics,
Economics, Statistics
John Von Neumann - CORRECT ANS Who founded Game Theory?
John Von Neumann - CORRECT ANS Who made the Monte Carlo Method?