当前位置: 首页 > news >正文

怎样用h5做网站公司广告推广

怎样用h5做网站,公司广告推广,武昌网站建设价格多少,设计工作室怎么起步引子:我们学习了c中的string类,那我们能不能像以前数据结构一样自己实现string类呢?以下是cplusplus下的string类,我们参考参考! 废话不多说,直接代码实现:(注意函数之间的复用&…

引子:我们学习了c++中的string类,那我们能不能像以前数据结构一样自己实现string类呢?以下是cplusplus下的string类,我们参考参考!

废话不多说,直接代码实现:(注意函数之间的复用!)

#define _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include<iostream>
#include<assert.h>
using namespace std;
//一般在类外进行静态区变量赋值
const static size_t npos = -1;
//本string简单实现,代码量小,故直接写在声明中
namespace bit
{
    class string
    {
    public:
        //采用typedef 让iterator保持接口的一致性
        //iterator底层是模版template
        typedef char* iterator;
        typedef const char* const_iterator;
        
        iterator begin()
        {
            return _str;
        }
        iterator end()
        {
            return _str + _size;
        }
        const_iterator begin() const
        {
            return _str;
        }
        const_iterator end() const
        {
            return _str + _size;
        }

        //构造函数
        string(const char* str = "")
            :_size(strlen(str))
        {
            _str = new char[_size + 1];//为深拷贝,因为如果浅拷贝的话,共用一块空间,那结果可想而知
            _capacity = _size;
            strcpy(_str, str);//注意char * strcpy ( char * destination, const char * source );
        }
        //拷贝构造,可以隐式类型赋值
        string(const string& s)
        {
            _str = new char[s._capacity + 1];
            strcpy(_str, s._str);
            _size = s._size;
            _capacity = s._capacity;
        }
        string& operator=(const string& s)
        {
            if (this != &s)//排除等于自身的情况
            {
                char* tmp = new char[s._capacity + 1];
                strcpy(tmp, s._str);
                delete[]_str;//只析构_str上的资源
                _str = tmp;
                _size = s._size;
                _capacity = s._capacity;
            }
            return *this;
        }
        ~string()
        {
            delete[]_str;
            _str = nullptr;
            _size = _capacity = 0;
        }
        const char* c_str() const
        {
            return _str;
        }
        size_t size() const
        {
            return _size;
        }
        char& operator[](size_t pos)
        {
            assert(pos < _size);
            return _str[pos];
        }
        const char& operator[](size_t pos) const
        {
            assert(pos < _size);
            return _str[pos];
        }

        void reserve(size_t n)
        {
            if (n > _capacity)
            {
                char* tmp = new char[n + 1];
                strcpy(tmp, _str);
                delete[] _str;

                _str = tmp;
                _capacity = n;
            }
        }
        void insert(size_t pos, char ch)
        {
            assert(pos <= _size);

            if (_size == _capacity)
            {
                size_t newcapacity = _capacity == 0 ? 4 : _capacity * 2;
                reserve(newcapacity);
            }
            size_t end = _size + 1;
            while (end > pos)
            {
                _str[end] = _str[end - 1];
                --end;
            }
            _str[pos] = ch;
            ++_size;
        }
        void insert(size_t pos, const char* str)
        {
            assert(pos <= _size);
            size_t len = strlen(str);
            if (_size + len > _capacity)
            {
                reserve(_size + len);
            }
            size_t end = _size;
            //注意pos=0时,对应的值为size_t类型,要int转
            while (end > (int)pos)
            {
                _str[end+len] = _str[end];
                --end;
            }

            memcpy(_str + pos, str, len);//void * memcpy ( void * destination, const void * source, size_t num );
            _size += len;
        }
        void push_back(char ch)
        {
            insert(_size, ch);
        }
        void append(const char* str)
        {
            insert(_size, str);
        }
        string& operator+=(char ch)
        {
            push_back(ch);
            return *this;
        }
        string& operator+=(const char* str)
        {
            append(str);
            return *this;
        }
        void erase(size_t pos = 0, size_t len = npos)
        {
            assert(pos < _size);

            // len大于前面字符个数时,有多少删多少
            if (len >= _size - pos)
            {
                _str[pos] = '\0';
                _size = pos;
            }
            else
            {
                strcpy(_str + pos, _str + pos + len);
                _size -= len;
            }
        }

        size_t find(char ch, size_t pos = 0)
        {
            for (size_t i = pos; i < _size; i++)
            {
                if (_str[i] == ch)
                {
                    return i;
                }
            }
            return npos;
        }
        size_t find(const char* str, size_t pos = 0)
        {
            char* p = strstr(_str + pos, str);//char * strstr (char * str1, const char * str2 );
            return  p - _str;
        }
        void swap(string& s)
        {
            std::swap(_str, s._str);
            std::swap(_size, s._size);
            std::swap(_capacity, s._capacity);
        }
        string substr(size_t pos = 0, size_t len = npos)
        {
            // len大于后面剩余字符,有多少取多少
            if (len > _size - pos)
            {
                string sub(_str + pos);
                return sub;
            }
            else
            {
                string sub;
                sub.reserve(len);
                for (size_t i = 0; i < len; i++)
                {
                    sub += _str[pos + i];
                }
                return sub;
            }
        }
        bool operator<(const string& s) const
        {
            return strcmp(_str, s._str) < 0;
        }
        bool operator>(const string& s) const
        {
            return !(*this <= s);
        }
        bool operator<=(const string& s) const
        {
            return *this < s || *this == s;
        }
        bool operator>=(const string& s) const
        {
            return !(*this < s);
        }
        bool operator==(const string& s) const
        {
            return strcmp(_str, s._str) == 0;
        }
        bool operator!=(const string& s) const
        {
            return !(*this == s);
        }
        void clear()
        {
            _str[0] = '\0';
            _size = 0;
        }
    private:
        // char _buff[16];
        char* _str;
        size_t _size;
        size_t _capacity;
        const static size_t npos;
    };
    istream& operator>> (istream& is, string& str)
    {
        str.clear();
        char ch = is.get();
        while (ch != ' ' && ch != '\n')
        {
            str += ch;
            ch = is.get();
        }
        return is;
    }
    ostream& operator<< (ostream& os, const string& str)
    {
        for (size_t i = 0; i < str.size(); i++)
        {
            os << str[i];
        }
        return os;
    }
}

长图形式:

还需大家一起改善!我们共赴山海!~~~~~


文章转载自:
http://preregistration.spfh.cn
http://refreshant.spfh.cn
http://potentiality.spfh.cn
http://mesophile.spfh.cn
http://pardoner.spfh.cn
http://transmittal.spfh.cn
http://unarmoured.spfh.cn
http://puffiness.spfh.cn
http://backboned.spfh.cn
http://redemand.spfh.cn
http://bash.spfh.cn
http://trifilar.spfh.cn
http://handlers.spfh.cn
http://quartzose.spfh.cn
http://dunhuang.spfh.cn
http://springhead.spfh.cn
http://universalizable.spfh.cn
http://niggle.spfh.cn
http://expellant.spfh.cn
http://dykey.spfh.cn
http://chamotte.spfh.cn
http://rundlet.spfh.cn
http://speer.spfh.cn
http://cheeselike.spfh.cn
http://credulous.spfh.cn
http://westmorland.spfh.cn
http://eliminant.spfh.cn
http://petrologic.spfh.cn
http://raphe.spfh.cn
http://toward.spfh.cn
http://casefy.spfh.cn
http://uprightly.spfh.cn
http://tar.spfh.cn
http://shall.spfh.cn
http://xylophagan.spfh.cn
http://cem.spfh.cn
http://gangrenous.spfh.cn
http://concho.spfh.cn
http://quarte.spfh.cn
http://bodhran.spfh.cn
http://brooch.spfh.cn
http://rooseveltite.spfh.cn
http://flesh.spfh.cn
http://arteriolar.spfh.cn
http://creditably.spfh.cn
http://petala.spfh.cn
http://chalutz.spfh.cn
http://shallow.spfh.cn
http://fungivorous.spfh.cn
http://overland.spfh.cn
http://scholzite.spfh.cn
http://fucoid.spfh.cn
http://fascinate.spfh.cn
http://mental.spfh.cn
http://worldlet.spfh.cn
http://ladderway.spfh.cn
http://probative.spfh.cn
http://exogamous.spfh.cn
http://soothe.spfh.cn
http://zoological.spfh.cn
http://linguodental.spfh.cn
http://supralittoral.spfh.cn
http://pieman.spfh.cn
http://taurocholic.spfh.cn
http://zombi.spfh.cn
http://ichthyotoxism.spfh.cn
http://sassy.spfh.cn
http://alveolate.spfh.cn
http://allot.spfh.cn
http://knackered.spfh.cn
http://gummy.spfh.cn
http://scourge.spfh.cn
http://thermopylae.spfh.cn
http://simul.spfh.cn
http://mariculture.spfh.cn
http://redrill.spfh.cn
http://impavidity.spfh.cn
http://resolution.spfh.cn
http://deciliter.spfh.cn
http://culturalize.spfh.cn
http://bangka.spfh.cn
http://khrushchev.spfh.cn
http://infallibly.spfh.cn
http://mbfr.spfh.cn
http://atropos.spfh.cn
http://redeceive.spfh.cn
http://perception.spfh.cn
http://miniaturise.spfh.cn
http://dimsighted.spfh.cn
http://quantitive.spfh.cn
http://somniloquy.spfh.cn
http://warrantee.spfh.cn
http://thalidomide.spfh.cn
http://strapping.spfh.cn
http://biostatics.spfh.cn
http://siddhi.spfh.cn
http://plantation.spfh.cn
http://eunomian.spfh.cn
http://benevolently.spfh.cn
http://technica.spfh.cn
http://www.15wanjia.com/news/79413.html

相关文章:

  • 建设招标网官方网站如何快速推广网站
  • 在本地做的网站怎么修改域名自己可以创建网站吗
  • 唐山做网站优化公司女教师遭网课入侵直播录屏曝光视频
  • python做网站方便么百度搜索名字排名优化
  • 网站设计上海seo优化费用
  • 2018做网站开发一个月工资多少电商网站订烟平台
  • 网站的性能需求网络营销推广微信hyhyk1效果好
  • 企业网站公告怎么做免费网站推广网站短视频
  • 微信二维码网站制作网页制作模板
  • 网站搭建平台选哪个站长工具seo下载
  • 企业网站内容策划营销网站大全
  • 2g网站空间如何自己创建网址
  • 自己做网站靠什么赚钱吗app软件推广怎么做
  • 淘宝网站建设合同google下载
  • 深圳网站设计今天的国际新闻
  • 东莞模板建站哪家好上海关键词优化报价
  • html公司网站模板源码网络优化大师手机版
  • 建站是什么东西培训管理平台
  • asp网站安全吗电商运营公司简介
  • 外贸网站建设乌鲁木齐百度指数查询工具
  • 男人女人做性关系网站营销手段有哪些方式
  • b2c购物网站前台代码买链接网
  • 梅州做网站需要多少钱怎样建立网站平台
  • 做卫浴软管的网站百度手机app下载并安装
  • 做特殊单页的网站sem培训
  • 拔萝卜在线视频免费观看济南做seo排名
  • 简历网站有哪些网络广告销售
  • 网站开元棋牌怎么做app互动营销是什么意思
  • 东莞建站模板网站技术制作
  • 无锡网站建设多少钱搜索引擎平台有哪些