File input and OCCF Flashcards
In C++ 11 how do you open a file?

When you open a file in C++, how do you test for end of file?

In C++ how do you read data from a file?

In C++ how do you grab single characters from a file (to build and parse a string youself)?

In C++ what are other ways (other than >>) to get input from a file?

In C++ how do you close a file and when should you do so?

How do you get the most up-to-date string library in C++?
How do you compare two strings?

How do you concatenate other data into a string in C++?

What does OCCF stand for?

What are the four things that every C++ class should have?

What is called when an object is deleted in C++?

What is the problem with destructors in C++?

What is the method called when an object is destructed in Java? When is it called?

What is the difference between a “shallow copy” and a “deep copy”?

In the attached code, which is a newly created object, shallow and deep copy?


In C++ what is the difference between a value parameter and a reference parameter?

How does this code work with regard to reference parameters?


What would happen in this code if we attempt to alter firstNode and have it point to newNode?


Why use reference parameters in C++?

How do we prevent a reference parameter from being altered in C++?

How do we make a copy constructor in C++?

How do default copy constructors work?

What are the two places where we make a copy of an argument implicitly

What is the clone method in Java and how do you overide it?
Object in Java has a method named clone that you can call vial super (super.clone( ))
Your class must implement a Clonable Interface and override the clone( ) method. clone ( ) might throw CloneNotSupportedException, so you have to throw or handle it as well.

What is Assignment in the context of OCCF?

In general, how to assignment overriding in C++ work?

How do you code an override for assignment operator in C++?

How does the assignment operator override in C++ work?
- Assumes that MyObject has a member data, and a method getData() to access it
- data here is actually this->data (implicitly)
- In other words, the left operand (of the = operator) is the instance on which we call the assignment “method”
- One more thing that’s very unusual is there’s a reference (&) in the return type - it’s actually modifying its “left” operand and then returns it (the new version)

In general what is overloading?

What are the OCCF’s so important in C++?

How does overriding operators work in Java?

How do you open and then read from a file in C++?
ifstream myFile;
myFile.open(“text.txt”);
string line;
getline(myFile, line);