Skip to content

Instantly share code, notes, and snippets.

View grayed's full-sized avatar
💭
C to C#: how much in this halftone

Vadim Zhukov grayed

💭
C to C#: how much in this halftone
  • self-employed, teacher at MIREA
  • Russia/Moscow
  • X @persgray
View GitHub Profile
@grayed
grayed / run-tests.log
Created October 5, 2020 19:55
running cheat.sh tests after POSIX sh tweaks under openbsd
(tests) 22:22 0 pers@persx240:~/cvs/cheat.sh/tests$ bash run-tests.sh
run-tests.sh: строка 13: realpath: команда не найдена
Using PYTHON 3: /home/pers/cvs/cheat.sh/tests/bin/python3
Using cht.sh client at ./share/cht.sh.txt
Running 1: python/:list
/home/pers/cvs/cheat.sh/tests/bin/python3 ../lib/standalone.py python/:list
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
@grayed
grayed / cpp-03-13-2021.cpp
Created March 13, 2021 15:01
C++ class task
#include <iostream>
class Number {
public:
virtual void print(std::ostream& os) const = 0;
virtual Number* sum(const Number& other) const = 0;
};
std::ostream& operator <<(std::ostream& os, const Number& n) { n.print(os); return os; }
class NaturalNumber : public Number
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <err.h>
#include <errno.h>
#include <netdb.h>
#include <string.h>
#include "stdafx.h"
#include <array>
#include <exception>
#include <iostream>
#include <cstdint>
#include <string.h>
// AUTORESIZE как...
// 1. Параметр шаблона
// 2. Изменение поведения при наследовании
#include <array>
#include <exception>
#include <iostream>
class BaseNumber {
public:
virtual void print(std::ostream& os) const = 0;
};
template<typename T>
#include <iostream>
template<typename T>
class MyArray {
T* p;
size_t sz;
public:
MyArray(size_t sz = 0) : p(new T[sz]) { }
// 1. Освобождение памяти
// 2. Сложение массивов
#include "stdafx.h"
#include <array>
#include <exception>
#include <iostream>
#include <climits>
#include <cstdint>
#include <string.h>
// AUTORESIZE как...
// 1. Параметр шаблона
// https://gist.github.com/grayed
// Application Programming Interface (API)
#include <iostream>
#include <exception>
template<typename T>
class MyArray {
struct MyArrayData {
MyArrayData(size_t sz_) : p(new T[sz_]), sz(sz_), allocated(sz_), refcnt(1) { }
MyArrayData(T* p_, size_t sz_) : p(p_), sz(sz_), allocated(sz_), refcnt(1) {}
#include <iostream>
#include <vector>
/*
* Написать программу, описывающую базу данных владельцев автомобилей.
* Класс автомобиля должен содержать ссылки/указатели на всех владельцев,
* а класс владельца должен содержать ссылки/указатели на все имеющиеся в наличии автомобили.
* Для каждого автомобиля должно быть реализовано свойство, показывающее количество владельцев.
*/
class Auto {
#include "stdafx.h"
#include <iostream>
#include <string>
#include <set>
class person;
class car
{
private: