COSC-1337 Chapter 7 Flashcards
What is data abstraction?
It is the separation between knowing a data type’s logical properties from its implementation details.
What are the two common methods in programming today?
Procedural programming and object oriented programming.
What is an access specifier?
public: / private: - this determines if the member variable or function is publicly accessible or not.
How would you write the class “Circle” with one private member variable and two public member functions?
class Circle {
private: double radius;
public: void setRadius(double r) { radius = r; }
double calcArea() { return 3.14*pow(radius, 2); }
};
Create two object of the class “Circle” named object1 and object2.
Then call the setRadius member function within the class circle with both object/s and pass arguments to them.
Circle object1, object2;
object1. setRadius(1.0);
object2. setRadius(2.5);
What is a member function that was created within a class declaration known as?
An “inline function”
What is a class member function called when it is defined outside of the class declaration?
Function implementation
How is a function implementation different than a regular function definition?
After you name the function return type, you must state the Class name, followed by a “double colon” “::”, followed by the name of the member function you are going to define, and then any parameters the member function may need.
Write the function implementation for the calArea member function from the class “Circle”
double Circle::calcArea() {
return 3.14*pow(radius, 2); }
What is the “double colon” in a function implementation called?
Scope resolution operator.
Should you declare your Classes and member function implementations BEFORE the main function?
Yes, this is so that the entire program has access to it.
What is the special memory location that is used when a function implementation is called?
Stack
_____________ is a member function that is automatically called when the when a class object is created?
A “constructor”
A constructor that has no parameters is known as a?
“Default constructor”
Do constructors have a return value?
Never