易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 :

python31与C交互

1.c调用python:
   实例代码:
main.c调用test.py的
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//main.c
#include <windows.h>
#include <python.h>
#include <stdio.h>
#include <stdlib.h>
int main(){
     Py_Initialize() ;//initialize the python system
    PyObject * py= PyImport_ImportModule("test");
    Py_Finalize();//Finalize  the python system
}
    
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ......

python31与C交互

1.c调用python:
   实例代码:
main.c调用test.py的
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//main.c
#include <windows.h>
#include <python.h>
#include <stdio.h>
#include <stdlib.h>
int main(){
     Py_Initialize() ;//initialize the python system
    PyObject * py= PyImport_ImportModule("test");
    Py_Finalize();//Finalize  the python system
}
    
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ......

C中括号优先级的思考

问题源于论坛的一道题目:
http://topic.csdn.net/u/20100216/21/ec98464e-a47e-4263-bb1c-a001e130ba87.html
下面是问题:
设int arr[]={6,7,8,9,10};
int *ptr=arr;
*(ptr++)+=123;
printf("%d,%d",*ptr,*(++ptr));
答案为什么是:8,8
问题的焦点也落在printf执行的问题上,到底先执行谁,后执行谁, 还有部分有才青年将该问题中庸化,觉得跟编译器有关。
执行的顺序真的跟编译器有关吗? 后面再讨论这个问题。
printf执行的问题, 完全可以归结函数执行顺序的通用问题, 所以,用例子来将该问题抽象化:
 #include <stdio.h>
int left()
{
printf("left \n");
return 0;
}
int right()
{
printf("right \n");
return 0;
}
int myFunction(int a, int b)
{
return 0;
}
int main()
{
myFunction(left(),right());
}
执行的结果是:
right
left
从中可以看出来, 括号中(理解为函数即可), 执行的顺序是先从右边,再从左边。
现在,再考虑编译器的影响, 我们说的编译器不是你自家开发的编译器, 这个世界上总有些BT的机构, 可能也会开发一个编译器,可能也搞些非常BT的功能(类似于咱移动喜欢 ......

C/C++编程必备

Windows C 程序设计入门与提高
http://download.chinaitlab.com/program/files/13246.html
单片机C语言入门
http://download.chinaitlab.com/program/files/12907.html
C++ 入门基础教程
http://download.chinaitlab.com/program/files/7617.html
C语言常用算法源代码
http://download.chinaitlab.com/program/files/12893.html
C常用算法程序集
http://download.chinaitlab.com/program/files/6225.html
C++ 语言命令详解
http://download.chinaitlab.com/program/files/4556.html
C语言编程要点
http://download.chinaitlab.com/program/files/11823.html
C语言编程基础
http://download.chinaitlab.com/program/files/11074.html
Borland c++使用手册
http://download.chinaitlab.com/program/files/4553.html
C语言数值算法程序大全(第二版)
http://download.chinaitlab.com/program/files/9247.html
Borland c++4.0安装与使用
http://download.chinaitlab.com/program/files/4546.html
C++ Builder 5.0经典入门
http://download.chinaitlab.com/program/files/4438.html
非C程序员C++入门自学教程
http://download.chinaitlab.com/program/file ......

C/C++编程必备

Windows C 程序设计入门与提高
http://download.chinaitlab.com/program/files/13246.html
单片机C语言入门
http://download.chinaitlab.com/program/files/12907.html
C++ 入门基础教程
http://download.chinaitlab.com/program/files/7617.html
C语言常用算法源代码
http://download.chinaitlab.com/program/files/12893.html
C常用算法程序集
http://download.chinaitlab.com/program/files/6225.html
C++ 语言命令详解
http://download.chinaitlab.com/program/files/4556.html
C语言编程要点
http://download.chinaitlab.com/program/files/11823.html
C语言编程基础
http://download.chinaitlab.com/program/files/11074.html
Borland c++使用手册
http://download.chinaitlab.com/program/files/4553.html
C语言数值算法程序大全(第二版)
http://download.chinaitlab.com/program/files/9247.html
Borland c++4.0安装与使用
http://download.chinaitlab.com/program/files/4546.html
C++ Builder 5.0经典入门
http://download.chinaitlab.com/program/files/4438.html
非C程序员C++入门自学教程
http://download.chinaitlab.com/program/file ......

Objective C 2.0 属性(Property)

原帖一:http://blog.csdn.net/dotphoenix/archive/2009/05/20/4203075.aspx
原贴二:http://www.cocoachina.com/bbs/read.php?tid-8008.html
@property (参数) 类型 名字;
这里的参数主要分为三类:读写属性(readwrite/readonly),setter语意(assign/retain/copy)以及atomicity(nonatomic)。
assign/retain/copy决定了以何种方式对数据成员赋予新值。我们在声明summary propery时使用了readonly,说明客户端只能对该property进行读取。atomicity的默认值是atomic,读取函数为原子操作。
在objective c 2.0下,由于我们声明了property,implementation文件可以更改如下:
可以看到数据成员title和numofpages的读写函数已经不复存在,取而代之的是两行@synthesize,
见下列示例代码:
 
//test.h
@interface MyTest : NSObject {
int myArray[5];
}
@end
 
如果采用
@property int myArray[5];
肯定会出错。
因为@property的声明指示编译器默认地给myArray添加了myArray以及setMyArray的这样一对getter和setter方法。由于objective-C中方法的返回类型不能是数组,所以上述声明property的方式是通不过编译的。
正确的方式是:
 
......

Objective C 2.0 简明教程 (5) 属性(Property)


Objective C 2.0 简明教程 (5) 属性(Property)





作者:Administrator
  

周六, 2009年 03月 28日 07:47
Objective C 2.0 为我们提供了property。它大大简化了我们创建数据成员读写函数的过程,更为关键的是它提供了一种更为简洁,易于理解的方式来访问数据成员。
我们先来看一下在Objective C 1.x下我们声明Book类的头文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//
// Book.h
 
#import <Cocoa/Cocoa.h>
 
 
@interface Book : NSObject {
NSString *title;
NSNumber* numofpages;
}
 
- (id)initWithTitle:(NSString*) booktitle andNumofpages:(NSNumber*) num;
 
- (NSString*) title;
- (void) setTitle:(NSString*)newtitle;
 
- (NSNumber*) numofpages;
- (void) setNumofpages:(NSNumber*)newnumofpages;
 
- (NSString*) summary;
 
@end
在Objective C 2.0下,我们可以通过声明与数据成员同名的property来省去读写函数的声明。代码如下所示:
1
2
3
4
5
6
7
8
9
10
......

数字表达式求值程序 (c/c++)

一个控制台下的数字表达式求值程序 (c/c++)
源代码见下:
#include <stdio.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <stack>
using namespace std;
//设置运算符优先级的算法
int Priority(const string opera) // 运算符优先级
{
    if(opera=="+"||opera=="-")
 {
  return (1);
 }
 else if(opera=="*"||opera=="/")
 {
  return (2);
 }
 else
 {
  return (0);
 }
}
void MiddlefixToPostfix(vector<string> &ivec1,vector<string> &ivec2)
//中缀表达式到后缀表达式的转换算法,ivec2中存放的是中缀表达式,将其转换为后缀表达式形式存放到ivec2中。
{
 //定义一个存放操作符的栈对象。
    stack<string> operatorstk; 
 
 for(vector<string>::size_type i=0;i!=ivec2.size();++i)
 {
        if(ivec2[i]=="(")
  {
&nb ......

数字表达式求值程序 (c/c++)

一个控制台下的数字表达式求值程序 (c/c++)
源代码见下:
#include <stdio.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <stack>
using namespace std;
//设置运算符优先级的算法
int Priority(const string opera) // 运算符优先级
{
    if(opera=="+"||opera=="-")
 {
  return (1);
 }
 else if(opera=="*"||opera=="/")
 {
  return (2);
 }
 else
 {
  return (0);
 }
}
void MiddlefixToPostfix(vector<string> &ivec1,vector<string> &ivec2)
//中缀表达式到后缀表达式的转换算法,ivec2中存放的是中缀表达式,将其转换为后缀表达式形式存放到ivec2中。
{
 //定义一个存放操作符的栈对象。
    stack<string> operatorstk; 
 
 for(vector<string>::size_type i=0;i!=ivec2.size();++i)
 {
        if(ivec2[i]=="(")
  {
&nb ......
总记录数:40319; 总页数:6720; 每页6 条; 首页 上一页 [2329] [2330] [2331] [2332] 2333 [2334] [2335] [2336] [2337] [2338]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号