All About Constructors
Public or Private?
ReMEMBER Functions?
What's Wrong?
Miscellaneous
100

 What is the main purpose of a constructor in C++?

To initialize an object

100

Is a constructor public or private?

Public

100

If a member function is void, it is a ___.

Setter

100

What is the error in this code:

void Employee:get_name(){return name;}

There has to be TWO colons.

100

What does OOP stand for?

Object Oriented Programming

200

This constructor has NO arguments/parameters 

Default Constructor

200

What is the process of providing a public interface while hiding the implementation details?

Encapsulation

200
In what functions do you use "const"(setters or getters)?

Getters

200

What is wrong with this piece of code?

Point::p(double x, double y){
    x_coord = x;
    y_coord = y;
}

It should be Point::Point

200

What month is Ms. B's birthday in?

March


300

DOUBLE JEOPARDY
What does a Constructor return?






300
True/False. Data members are public

False

300

What are the two main types of member functions(formal name)?

Mutators and Accessors

300

What's wrong with this code?


Point::Point(double x, double y)
{
    x_coord = x;
    y_coord = y;
}

int main()
{
    double x1;
    Point p1(x1);
}

In int main, the object only contains one parameter, but the constructor needs two to run.


300

How many sections were in this unit?

6

400

Where are constructors declared?

Inside the class definition

400

What is in the public interface?

All Member Functions

400

Do you start with accessor or mutator functions when defining a class?

Accessor

400

What's wrong with this?

class Point

{

    private:

    double x_coord;

    double y_coord;

    void set_x_coord(double x); 

    void set_y_coord(double y);


    public:
    double get_x_coord() const;
    double get_y_coord() const;
};

The setter functions should be in the public part of the class

400
What is the main difference between a structure and class?
  • In structures, members are public by default.
  • In classes, members are private by default.
500

The class NishantLikesBrownies has a constructor...
What is the best possible name for this constructor?

NishantLikesBrownies

(bonus points if italicized)

500

Because accessors verify and change the object... 

what type of value should they return?

Trick Question.... Acessors dont change the object!

500

What do you use to mark accessor functions?

CONST

500

What's wrong with this code?

#include <iostream>
using namespace std;

class Rectangle
{
    private: //members
    double length;
    double width;
   
    public: //functions
    void set_length(double l);
    void set_width(double w);
    double get_length();
    double get_width();
}

A semicolon is missing at the very end... similar to struct

500

DOUBLE JEOPARDY

What was the first example used to model a class?

Tally Counter

M
e
n
u