__attribute__((packed))的作用
在结构体变量的声明中,经常可以看到__attribute__((packed))修饰符。这是做什么用的呢?请看一下程序:
#define u8 unsigned char
#define u16 unsigned short
#define u32 unsigned int
int main()
{
struct {
...
分类:
其他好文 时间:
2014-05-13 06:19:18
阅读次数:
416
之前没有用过枚举,不懂。今天找了些资料学习了,现在总结如下:(希望高手看到后批评指教)枚举的作用:1、限定某一类型的取值范围。2.不再写public
static final...(如果取值范围太广,就太麻烦了),但最终enum还是要转化成class类型,还是会加public static fina...
分类:
编程语言 时间:
2014-05-12 22:22:57
阅读次数:
400
#include #include #include #include #include
#include #include #include #include #include using namespace std;struct
MyStruct{ string stru; int ...
分类:
其他好文 时间:
2014-05-12 21:51:09
阅读次数:
572
其题目如下:#pragma pack(2)class A{public: int
i; union U { char buff[13]; int i; }u; void foo() { } typedef char*
(*f)(void*); enum{red, green, blue} ...
分类:
其他好文 时间:
2014-05-12 21:18:19
阅读次数:
321
在学习linux下编程时,不可避免的要学C了,下面先简单写写C下对C++中的类的模拟。我们要用到的是
struct和函数指针,不懂的同学自行搜索这两个东东,我现在只写我的第一个实现,更多实现方式我会稍后补充。首先先上代码: 1 #include 2
#include 3 4 struct Swen....
分类:
编程语言 时间:
2014-05-12 02:45:26
阅读次数:
279
邻接矩阵的图示:
构建一个这样的无向邻接矩阵。
参考网站: http://www.geeksforgeeks.org/graph-and-its-representations/
这里写了个类,增加删除图的操作。
#pragma once
#include
#include
class AdjListGraph
{
struct Node
{
int dest;
...
分类:
其他好文 时间:
2014-05-11 22:44:20
阅读次数:
378
这里用邻接表实现图的深度优先遍历,采用递归实现。
#include
using namespace std;
#define VERTEXNUM 5//结点数
struct edgenode
{
int to;
int weight; // 边的权值
edgenode *next;
};
struct vnode
{
int from...
分类:
其他好文 时间:
2014-05-11 20:46:16
阅读次数:
519
产生原因:多文件包含时,全局变量未用extern解决方法:直接在全局变量前加上extern即可,若要在在其他文件中使用,该变量声明下就ok了~~另外引出一个话题,你是不是也发现了这么一个现象??比如A.hA.cpp#include
"A.h"#include "B.h"HWND ui_hwnd, h...
分类:
其他好文 时间:
2014-05-11 17:25:39
阅读次数:
526
typedef enum
//{
// GPIO_PIN_0 = ((u8)0x01), /*!
// GPIO_PIN_1 = ((u8)0x02), /*!
// GPIO_PIN_2 = ((u8)0x04), /*!
// GPIO_PIN_3 = ((u8)0x08), /*!
// GPIO_PIN_4 = ((u8)0x1...
分类:
其他好文 时间:
2014-05-11 07:10:01
阅读次数:
517
//链表操作:建立、插入、删除、查找、倒置、删除等基本操作
#include
#include
typedef
struct LNode
{
int data;
structLNode *next;
}LNode,*Llist;
LNode *creat_head();//创建一个空表
void creat_list(LNode *,int);//创...
分类:
其他好文 时间:
2014-05-11 03:33:11
阅读次数:
351