This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <stdexcept> | |
std::string encrypt(std::string const& plaintext) { | |
if (plaintext.length() <= 4) | |
throw std::runtime_error("Invalid string length."); | |
std::string first; | |
std::string second; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PointBad { | |
private: | |
int x_; | |
public: | |
PointBad(int x) : x_(x) {} | |
int GetX() { | |
return this->x_; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PointGood { | |
private: | |
int x_; | |
public: | |
PointGood(int x) : x_(x) {} | |
int GetX() const { | |
return this->x_; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PointBroken { | |
private: | |
int x_; | |
public: | |
PointBroken(int x) : x_(x) {} | |
int GetX() const { | |
this->x_ = 7; // Compiler error: not allowed to modify this->x_. | |
return this->x_; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PointAgainBroken { | |
private: | |
int x_; | |
void SetXToSeven() { | |
this->x_ = 7; | |
} | |
public: | |
PointAgainBroken(int x) : x_(x) {} | |
int GetX() const { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef HAND_H | |
#define HAND_H | |
// string is not IO. | |
#include <string> | |
// For random | |
#include <cstdlib> | |
class hand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <memory> | |
#include <stack> | |
#include <vector> | |
#include <iostream> | |
#include <functional> | |
// Stores an overview of everything. It is very easy to get this wrong; | |
// try to keep as few things as possible directly in this class, and as | |
// much as possible in more focused classes. | |
class World; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Don't forget to label as C++. | |
#include <iostream> | |
// No need to use the std namespace. | |
int main() { | |
// Arrows in the wrong direction, and forgot a newline at the end of the string. | |
std::cout << "This is used to find the slope of the line. Please enter two points.\n"; | |
// No need to use new here. | |
float y1, y2, x1, x2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <limits> | |
#include <sstream> | |
#include <string> | |
#include <vector> | |
int main() { | |
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); | |
for (std::string line; std::getline(std::cin, line);) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
/* | |
* Programming Assignment 02 | |
* This program will accept, from the user, the type of recreational equipment | |
* being rented, as well as the duration of the rental. It will then display a | |
* summary of the sale, first listing the duration of the rental, then the | |
* recreational equipment being rented, and then the total cost of the rental. | |
* | |
* Program Preconditions | |
* 1. The user will enter the type of equipment rental, which will be S for |
OlderNewer