Skip to content

Instantly share code, notes, and snippets.

@krysseltillada
krysseltillada / TmpContainer .h
Created September 27, 2015 17:43
template Vector header and implementation
#pragma once
#ifndef TMPCONTAINER_HEADER
#define TMPCONTAINER_HEADER
#include <vector>
#include <memory>
template <typename type>
class Vector {
public:
@krysseltillada
krysseltillada / Author.cpp
Created September 26, 2015 18:50
Class headers and implementations
#include "Author.h"
std::ostream& operator << (std::ostream &os, const Author &a) {
os << a.Email << " " << a.Name << " " << a.Gender;
return os;
}
Author::Author (const std::string &n, const std::string &e, const char &g) :
Name (n), Email (e), Gender (g) { }
@krysseltillada
krysseltillada / Quote.h
Created September 22, 2015 15:09
inherited constructors
#pragma once
#ifndef QUOTE_H
#define QUOTE_H
#include <iostream> /// std::cout, std::ostream
#include <utility> /// std::pair, std::move
class Quote {
public:
@krysseltillada
krysseltillada / s_tree.h
Created September 10, 2015 19:31
skill tree header
#pragma once
#ifndef CLASS_HEADER
#define CLASS_HEADER
#include <vector>
#include <iostream>
struct skill_info {
skill_info () = default;
skill_info (const std::string &n, const std::string &des, const int &lvl, const double &cd) :
@krysseltillada
krysseltillada / String.cpp
Created August 29, 2015 06:52
Custom String class container
#include "String.h"
/// implementation section
namespace Custom {
std::allocator <char> String::a_mem;
String::String (const char *c_char)
{
@krysseltillada
krysseltillada / e_951a.cpp
Created July 27, 2015 08:43
exercise 9.5.1(a)
#include <iostream>
#include <vector>
#include <string>
int main ()
{
const size_t sz = 2;
char c_str[] = {'2', '3'};
std::vector <char> c;
@krysseltillada
krysseltillada / ex9_31b.cpp
Created July 26, 2015 05:19
exercise 9.31 (b)
#include <iostream>
#include <list>
int main ()
{
std::list <int> v1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
auto curr = v1.begin();
while (curr != v1.end()) {
@krysseltillada
krysseltillada / ex9_31.cpp
Created July 26, 2015 05:17
exercise 9.31 (a)
#include <iostream>
#include <forward_list>
int main ()
{
std::forward_list <int> v1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
auto curr = v1.begin();
auto prev = v1.before_begin ();
@krysseltillada
krysseltillada / fl.cpp
Created July 25, 2015 16:52
std::forward_list
#include <iostream>
#include <string>
#include <forward_list>
void add_str (std::forward_list <std::string> flst, std::string str1 = "", std::string str2 = "") {
if (!str1.empty()) {
flst.insert_after (flst.before_begin(), str2);
flst.insert_after (flst.before_begin(), str1);
} else {
flst.insert_after (flst.before_begin(), str2);
@krysseltillada
krysseltillada / e_o.cpp
Created July 25, 2015 11:49
std::erase
#include <iostream>
#include <list>
#include <vector>
int main ()
{
int ia[11] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 55, 89}; /// declare and define ia as int array that has a size of 11 (built in array)
std::list <int> lst (std::begin(ia), std::end(ia)); /// initialize a value range from one past to the end of the array
std::vector <int> v1 (std::begin(ia), std::end(ia)); /// same