C++ Exam2 Flashcards

1
Q

Class Specification File

Example:

A
// class specifiation file 
#ifndef RECTANGLE\_H
#define RECTANGLE\_H
// class declaration 
class Rectangle
{
 private: 
 double length; 
 double width;
 public: 
 bool setLength(double);
 bool setWidth(double);
 double getLength();
 double getWidth();
 double calcArea(); 
 };
 #endif
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Class Function Implementation File

Example

A
// class function implementation file
#include "Rectangle.h"

bool Rectangle::setLength(double len)
{
bool validData = true;a

if (len >= 0)
length = len;
else
validData = false;

return validData;
}

bool Rectangle::setWidth(double w)
{
bool validData = true;

if (w >= 0)
width = w;
else
validData = false;

return validData;
}

double Rectangle::getLength()
{
return length;
}

double Rectangle::getWidth()
{
return width;
}

double Rectangle::calcArea()
{
return length * width;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

API stands for Application Programming Interface

A

In computer programming, an application programming interface is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components.

A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer.

An API may be for a web-based system, operating system, database system, computer hardware, or software library.

A set of functions and procedures allowing the creation of applications that access the features or data of an operating system, application, or other service.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

JSON

A

JavaScript Object Notation and is basically a way of representing data that looks like JavaScript objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

documentation

A

In computer hardware and software product development, documentation is the information that describes the product to its users. … The term is also sometimes used to mean the source information about the product contained in design documents, detailed code comments, white papers, and blackboard session notes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

bubble sort

A

bubble sort - ascending or descending - swaps adjacent elements - first pass -

inefficient for large arrays because of the repeated swaps and passes

void sort(int num[], int x)

{

int temp;

bool swap;

do

{ swap = false;

for (int y = 0; y < (x-1); y++) // one minus the actual size because the

if statement will compare the next highest value

{

if (num[y] > num[y+1])

{

temp = num[y];

num [y] = num[y+1];

num[y+1] = temp;

swap = true;

}

}

}while(swap);

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

struct defined and intialized

A

struct Date

{

int month,

day,

year;

};

Date JasonBday = {1, 29, 1981); // Date variable defined and initialized

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

structure declaration

A

// structure declaration

struct Employee {

string name;

int vacationDays,

daysUsed;

Employee(string n = “”, int d = 0) // Default constructor

{

name = n;

vacationDays = 10;

daysUsed = d;

}

};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

passing structures to functions

A

preferable to pass by constant reference to functions

void showIte(const InvItem &); // Prototype

void showItem(const InvItem &item) // Header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

simple PayRoll struct

A

struct PayRoll // Initialization list (set of memory locations)

{

int empNumber;

string name;

double hours,

payRate,

grossPay;

};

Payroll deptHead, foreman, associate; // Define variables of the Payroll

structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

PayRoll struct continued

A

deptHead.empNumber = 475;

foreman.empNumber = 897;

associate.empNumber = 729;

cout << “Enter the employee’s name: “; // example of input into a member

variable of the Payroll struct

getline(cin, associate.name);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly