TODO:Go语言同名Go字体发布

TODO:Go语言同名Go字体发布

2016-11-16 Go语言官方博客发布了一款同名字体–Go字体。此字体族包括正常、粗体和斜体渲染,支持比例和等宽字体。此字体已经经过用于编程方面的技术测试,使用Go字体显示,Go源码看起来非常漂亮,名副其实。标点符号容易辨识,操作符排列一致。如图

小编尝鲜了一翻,安装了实验性的用户工具箱有一些和文本元素相关的内容的golang包:golang.org/x/exp/shiny,录制了shiny的例子fluid的视频,主要是点击鼠标左键,按住鼠标左键移动,请欣赏。

 

wxgzh:ludong86

qrcode_for_gh_6bb1f39ae99c_258

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
填充下面这个程序中所有出现// TODO: fill the code这个任务的地方#include <iostream> #include <cstring> #include "ourstring.h" #include "strlib.h" using namespace std; OurString::OurString(){ // TODO: fill the code } OurString::OurString(const char *str){ // TODO: fill the code } OurString::OurString(const OurString &dstr){ // TODO: fill the code } OurString::~OurString(){ // TODO: fill the code } string OurString::toString() const{ // TODO: fill the code } OurString OurString::subStr(unsigned int start, unsigned int n) const{ // TODO: fill the code } bool OurString::operator > (const OurString &dstr) const{ // TODO: fill the code } bool OurString::operator < (const OurString &dstr) const{ // TODO: fill the code } bool OurString::operator == (const OurString &dstr) const{ // TODO: fill the code } unsigned int OurString::length () const{ // TODO: fill the code } const OurString& OurString::operator = (const OurString &dstr){ // TODO: fill the code } const OurString& OurString::operator = (const char *str){ // TODO: fill the code } char& OurString::operator[](int index){ // TODO: fill the code } const OurString OurString::operator + (const OurString &dstr) const{ // TODO: fill the code } const OurString OurString::operator + (const char *str) const{ // TODO: fill the code } const OurString& OurString::operator += (const OurString &dstr){ // TODO: fill the code } const OurString& OurString::operator += (const char *str){ // TODO: fill the code } ostream & operator<<(ostream &os, const OurString &dstr){ // TODO: fill the code } istream & operator>>(istream &is, OurString &dstr){ // TODO: fill the code }
05-29
好的,下面是填充后的代码,每个 TODO 已经被替换成相应的实现: ```c++ #include <iostream> #include <cstring> #include "ourstring.h" #include "strlib.h" using namespace std; OurString::OurString(){ str = new char[1]; str[0] = '\0'; } OurString::OurString(const char *str){ this->str = new char[strlen(str)+1]; strcpy(this->str, str); } OurString::OurString(const OurString &dstr){ this->str = new char[dstr.length()+1]; strcpy(this->str, dstr.str); } OurString::~OurString(){ delete [] str; } string OurString::toString() const{ return string(str); } OurString OurString::subStr(unsigned int start, unsigned int n) const{ if (start >= length()) return OurString(); n = (n > length() - start) ? length() - start : n; return OurString(str + start, str + start + n); } bool OurString::operator > (const OurString &dstr) const{ return strcmp(str, dstr.str) > 0; } bool OurString::operator < (const OurString &dstr) const{ return strcmp(str, dstr.str) < 0; } bool OurString::operator == (const OurString &dstr) const{ return strcmp(str, dstr.str) == 0; } unsigned int OurString::length () const{ return strlen(str); } const OurString& OurString::operator = (const OurString &dstr){ if (this != &dstr) { delete [] str; str = new char[dstr.length()+1]; strcpy(str, dstr.str); } return *this; } const OurString& OurString::operator = (const char *str){ if (this->str != str) { delete [] this->str; this->str = new char[strlen(str)+1]; strcpy(this->str, str); } return *this; } char& OurString::operator[](int index){ return str[index]; } const OurString OurString::operator + (const OurString &dstr) const{ OurString s; s.str = new char[length() + dstr.length() + 1]; strcpy(s.str, str); strcat(s.str, dstr.str); return s; } const OurString OurString::operator + (const char *str) const{ OurString s; s.str = new char[length() + strlen(str) + 1]; strcpy(s.str, this->str); strcat(s.str, str); return s; } const OurString& OurString::operator += (const OurString &dstr){ *this = *this + dstr; return *this; } const OurString& OurString::operator += (const char *str){ *this = *this + str; return *this; } ostream & operator<<(ostream &os, const OurString &dstr){ os << dstr.str; return os; } istream & operator>>(istream &is, OurString &dstr){ string s; is >> s; dstr = s.c_str(); return is; } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值