
C++
文章平均质量分 81
gacmy
这个作者很懒,什么都没留下…
展开
-
using例子
#include<iostream>using namespace std;namespace game1{int id = 10;};namespace game2{int id = 20;};void testHowUse(){ cout << game1::id << endl; cout << game2::id << endl;}void selectWho1(){ using namesp原创 2020-12-23 11:25:35 · 193 阅读 · 0 评论 -
C++自增自减重载
#include using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop *///前置运算符 ++i //重载为成员函数//T operator++()//T operator--()//原创 2015-08-22 16:19:33 · 1964 阅读 · 0 评论 -
VS2010下安装boost库
1.去www.boost.org下载最新的boost,我下载了boost_1_46_1.7z2.(我放在D:/cpp目录下)解压到当前文件夹3.打开VS2010->VS TOOLS->VS命令提示4.CD D:/cpp/boost_1_46_1 5.输入bootstrap,便生成bjam.exe文件6.输入bjam toolset=msvc-10.0 variant=debug转载 2015-09-15 14:35:55 · 441 阅读 · 0 评论 -
vs2010配置安装使用log4cplus日志系统
log4cplus是C++编写的开源的日志系统,功能非常全面,用到自己开发的工程中会比较专业的,:),本文介绍了log4cplus基本概念,以及如何安装,配置。 ### 简介 ###log4cplus是C++编写的开源的日志系统,前身是java编写的log4j系统.受Apache Software License保护。作者是Tad E. Smith。log4cplus具有线程安全、灵活原创 2015-09-15 13:25:40 · 2514 阅读 · 0 评论 -
jsoncpp编译方法 和 vs2010中导入第三方库的方法
详细地jsoncpp编译方法 和 vs2010中导入第三方库的方法一 编译链接 1 在相应官网下载jsoncpp 2 解压得到jsoncpp-src-0.5.0文件 3 打开jsoncpp-src-0.5.0 -> makefiles -> vs71 -> jsoncpp.sln4 转换项目为VS2010格式 5 选择debug模式 6 在“解决方案转载 2015-09-17 16:22:46 · 1791 阅读 · 0 评论 -
创建使用动态链接库
此分步演练演示如何创建用于 C++ 应用的动态链接库 (DLL)。 使用库是重复使用代码的一种绝佳方式。与其在创建的每个程序中重新实现相同的例程,不如一次性编写它们,然后从需要该功能的应用中引用它们。通过将代码置入 DLL,可以节省引用它的每个应用中的空间,也可以更新该 DLL 而无需重新编译所有应用。有关 DLL 的详细信息,请参阅 Visual C++ 中的 DLL。本演练原创 2015-09-18 12:45:41 · 1028 阅读 · 0 评论 -
动态链接库加载的两种方法
动态链接库加载的两种方法1.隐式链接2.显示加载一.隐式链接创建Win32 Dynamic-Link Library程序Dll1Dll1.cpp文件[cpp] view plaincopy#define DLL1_API extern "C" _declspec(dllexport)//用了extern "C"就不能导出类了,只能导出全局函数转载 2015-09-18 17:16:55 · 1587 阅读 · 0 评论 -
windows socket简单封装
一个简单的Windows Socket可复用框架 说起网络编程,无非是建立连接,发送数据,接收数据,关闭连接。曾经学习网络编程的时候用Java写了一些小的聊天程序,Java对网络接口函数的封装还是很简单实用的,但是在Windows下网络编程使用的Socket就显得稍微有点繁琐。这里介绍一个自己封装的一个简单的基于Windows Socket的一个框架代码,主要目的是为了方便使用Wind转载 2015-10-10 10:24:20 · 1551 阅读 · 0 评论 -
windows socket简单编程
一。 server端: 1 #include "stdafx.h" 2 #include 3 #include 4 5 #pragma comment(lib,"ws2_32.lib") 6 7 int main(int argc, char* argv[]) 8 { 9 //初始化WSA10 WORD sockVersion = MAK转载 2015-10-10 09:34:52 · 481 阅读 · 0 评论 -
动态链接库的创建以及两种调用方式
创建动态连接库vs2010创建项目 控制台项目 选择动态链接库项目属性-配置属性-常规: 配置类型 动态库dll MFC的使用 在共享Dll中使用MFC项目属性- C/C++代码生成-运行库: 多线程调试 DLL/(MDd)创建函数的头文件:testdll.hint add(int a,int b);创建函数的定义文件testdll.c原创 2015-09-21 15:20:12 · 640 阅读 · 0 评论 -
char* BSTR CString 之间转换
(1) char*转换成CString 若将char*转换成CString,除了直接赋值外,还可使用CString::Format进行。例如:[cpp] view plaincopychar chArray[] = "This is a test"; char * p = "This is a test"; 或[cpp] view转载 2015-09-07 10:15:45 · 575 阅读 · 0 评论 -
C++栈的实现
#include#includetypedef double DataType;const int MaxStackSize = 50;class Stack{ private: DataType stacklist[MaxStackSize]; int top; public: Stack(void);原创 2015-08-21 16:37:51 · 658 阅读 · 0 评论 -
流运算符重载
#include #include#include/* run this program using the console pauser or add your own getch, system("pause") or input loop */using namespace std; class CStudent{ public: int nAge;};原创 2015-08-22 16:56:48 · 734 阅读 · 0 评论 -
运算重载实现可变长数组
#include #include /* run this program using the console pauser or add your own getch, system("pause") or input loop */class CArray{ int size;//数组元素个数 int *ptr;//指向动态分配的数组原创 2015-08-22 16:45:33 · 943 阅读 · 0 评论 -
C++多态基础
#include /* run this program using the console pauser or add your own getch, system("pause") or input loop *//*多态: 派生类的指针可以赋给基类指针 base* = child; 通过基类指针调用基类和派生类中的同名虚函数时, 若该指针指向一原创 2015-08-25 09:51:33 · 559 阅读 · 0 评论 -
纯虚函数和虚析构函数
//纯虚函数 没有函数体的函数class A{ private: int a; public: virtual void Print() = 0;//纯虚函数 void fun(){ cout } }; //包括纯虚函数的类就是抽象类//只能作为基类来派生新类使用原创 2015-08-25 11:22:15 · 796 阅读 · 0 评论 -
多态应用实例1
#include#include#includeusing namespace std;class CShape{ public: virtual double Area() = 0;//纯虚函数 virtual void PrintInfo() = 0; }; class CRectangle:public CShape原创 2015-08-25 11:35:22 · 573 阅读 · 0 评论 -
多态应用举例2
#includeclass Base{ public: void fun1(){ this->fun2();//this 基类指针 fun2虚函数 所以是多态 } virtual void fun2(){ cout }};class Derived:原创 2015-08-25 11:40:39 · 801 阅读 · 0 评论 -
基数排序的设计实现 队列应用
//Queue.h实现const int MaxQSize = 50;struct Person{ char name[20]; char sex;//F M};typedef int DataType;class Queue{ private: int front,rear,count; DataT原创 2015-08-25 15:07:08 · 755 阅读 · 0 评论 -
优先队列C++实现和应用
#include#includeusing namespace std;//优先级队列数组元素的个数const int MaxPQSize = 50;templateclass PQueue{ private: int count; T pqlist[MaxPQSize]; public: PQueu原创 2015-08-26 16:49:01 · 1920 阅读 · 0 评论 -
com编程基础和QueryInterface函数的实现原理例子
所有的com接口都继承IUnknown接口,接口定义在win32SDK UNKNWN.h文件中interface IUnknown{ virtual HRESULT _stdcall QueryInterface(const&IID iid,void *ppv) = 0; virtual ULONG _stdcall AddRef()=0; virtual ULO原创 2015-09-01 10:52:05 · 918 阅读 · 0 评论 -
函数模板
anjoyo贴吧 (0)原创 2014-03-11 22:16:57 · 538 阅读 · 0 评论