文档库 最新最全的文档下载
当前位置:文档库 › static用法小结

static用法小结

static用法小结
static用法小结

static关键字是C, C++中都存在的关键字, 它主要有三种使用方式, 其中前两种只指在C语言中使用, 第三种在C++中使用(C,C++中具体细微操作不尽相同, 本文以C++为准).

(1)局部静态变量

(2)外部静态变量/函数

(3)静态数据成员/成员函数

下面就这三种使用方式及注意事项分别说明

一、局部静态变量

在C/C++中, 局部变量按照存储形式可分为三种auto, static, register

(谭浩强, 第174-175页)

与auto类型(普通)局部变量相比, static局部变量有三点不同

1. 存储空间分配不同

auto类型分配在栈上, 属于动态存储类别, 占动态存储区空间, 函数调用结束后自动释放, 而static分配在静态存储区, 在程序整个运行期间都不释放. 两者之间的作用域相同, 但生存期不同.

2. static局部变量在所处模块在初次运行时进行初始化工作, 且只操作一次

3. 对于局部静态变量, 如果不赋初值, 编译期会自动赋初值0或空字符, 而auto类型的初值是不确定的. (对于C++中的class对象例外, class的对象实例如果不初始化, 则会自动调用默认构造函数, 不管是否是static类型)

特点: static局部变量的”记忆性”与生存期的”全局性”

所谓”记忆性”是指在两次函数调用时, 在第二次调用进入时, 能保持第一次调用退出时的值.

示例程序一

#include

using namespace std;

void staticLocalVar()

{

static int a = 0; // 运行期时初始化一次, 下次再调用时, 不进行初始化工作

cout<<"a="<

++a;

}

int main()

{

staticLocalVar(); // 第一次调用, 输出a=0

staticLocalVar(); // 第二次调用, 记忆了第一次退出时的值, 输出a=1

return 0;

}

应用:

利用”记忆性”, 记录函数调用的次数(示例程序一)

利用生存期的”全局性”, 改善”return a pointer / reference to a local object”的问题. Local object的问题在于退出函数, 生存期即结束,. 利用static的作用, 延长变量的生存期.

示例程序二:

// IP address to string format

// Used in Ethernet Frame and IP Header analysis

const char * IpToStr(UINT32 IpAddr)

{

static char strBuff[16]; // static局部变量, 用于返回地址有效

const unsigned char *pChIP = (const unsigned char *)&IpAddr;

sprintf(strBuff, "%u.%u.%u.%u", pChIP[0], pChIP[1], pChIP[2], pChIP[3]);

return strBuff;

}

注意事项:

1. “记忆性”, 程序运行很重要的一点就是可重复性, 而static变量的”记忆性”破坏了这种可重复性, 造成不同时刻至运行的结果可能不同.

2. “生存期”全局性和唯一性. 普通的local变量的存储空间分配在stack上, 因此每次调用函数时, 分配的空间都可能不一样, 而static具有全局唯一性的特点, 每次调用时, 都指向同一块内存, 这就造成一个很重要的问题---- 不可重入性!!!

这样在多线程程序设计或递归程序设计中, 要特别注意这个问题.

(不可重入性的例子可以参见(影印版)第103-105页)

下面针对示例程序二, 分析在多线程情况下的不安全性.(为方便描述, 标上行号)

①const char * IpToStr(UINT32 IpAddr)

②{

③static char strBuff[16]; // static局部变量, 用于返回地址有效

④const unsigned char *pChIP = (const unsigned char *)&IpAddr;

⑤sprintf(strBuff, "%u.%u.%u.%u", pChIP[0], pChIP[1], pChIP[2], pChIP[3]);

⑥return strBuff;

⑦}

假设现在有两个线程A,B运行期间都需要调用IpToStr()函数, 将32位的IP地址转换成点分10进制的字符串形式. 现A先获得执行机会, 执行IpToStr(), 传入的参数是0x0B090A0A, 顺序执行完应该返回的指针存储区内容是:”10.10.9.11”, 现执行到⑥时, 失去执行权, 调度到B线程执行, B线程传入的参数是0xA8A8A8C0, 执行至⑦, 静态存储区的内容是192.168.168.168. 当再调度到A执行时, 从⑥继续执行, 由于strBuff的全局唯一性, 内容已经被B线程冲掉, 此时返回的将是192.168.168.168字符串, 不再是10.10.9.11字符串.

二、外部静态变量/函数

在C中static有了第二种含义:用来表示不能被其它文件访问的全局变量和函数。, 但为了限制全局变量/函数的作用域, 函数或变量前加static使得函数成为静态函数。但此处“static”的含义不是指存储方式,而是指对函数的作用域仅局限于本文件(所以又称内部函数)。注意此时, 对于外部(全局)变量, 不论是否有static限制, 它的存储区域都是在静态存储区, 生存期都是全局的. 此时的static只是起作用域限制作用, 限定作用域在本模块(文件)内部.

使用内部函数的好处是:不同的人编写不同的函数时,不用担心自己定义的函数,是否会与其它文件中的函数同名。

示例程序三:

//file1.cpp

static int varA;

int varB;

extern void funA()

{

……

}

static void funB()

{

……

}

//file2.cpp

extern int varB; // 使用file1.cpp中定义的全局变量

extern int varA; // 错误! varA是static类型, 无法在其他文件中使用

extern vod funA(); // 使用file1.cpp中定义的函数

extern void funB(); // 错误! 无法使用file1.cpp文件中static函数

三、静态数据成员/成员函数(C++特有)

C++重用了这个关键字,并赋予它与前面不同的第三种含义:表示属于一个类而不是属于此类的任何特定对象的变量和函数. 这是与普通成员函数的最大区别, 也是其应用所在, 比如在对某一个类的对象进行计数时, 计数生成多少个类的实例, 就可以用到静态数据成员. 在这里面, static既不是限定作用域的, 也不是扩展生存期的作用, 而是指示变量/函数在此类中的唯一性. 这也是”属于一个类而不是属于此类的任何特定对象的变量和函数”的含义. 因为它是对整个类来说是唯一的, 因此不可能属于某一个实例对象的. (针对静态数据成员而言, 成员函数不管是否是static, 在内存中只有一个副本, 普通成员函数调用时, 需要传入this指针, static成员函数调用时, 没有this指针. )

请看示例程序四((影印版)第59页)

class EnemyTarget {

public:

EnemyTarget() { ++numTargets; }

EnemyTarget(const EnemyTarget&) { ++numTargets; }

~EnemyTarget() { --numTargets; }

static size_t numberOfTargets() { return numTargets; }

bool destroy(); // returns success of attempt to destroy EnemyTarget object

private:

static size_t numTargets; // object counter

};

// class statics must be defined outside the class;

// initialization is to 0 by default

size_t EnemyTarget::numTargets;

在这个例子中, 静态数据成员numTargets就是用来计数产生的对象个数的.

另外, 在设计类的多线程操作时, 由于POSIX库下的线程函数pthread_create()要求是全局的, 普通成员函数无法直接做为线程函数, 可以考虑用Static成员函数做线程函数.

keep 的用法

Keep的用法: keep vt., vi. kept, keeping 保留;保守 I keep old letters.我保存旧信。 I'll keep the original copy of your report on file. 我会把你报告的原件归档的。 It's an interesting suggestion and we'll keep it on ice." 这是一项有趣的建议,我们将留待以后考虑采用。" 保持;继续 We will keep on trying and, if we get anything done, will notify you. 我们将继续努力,有结果将通知你。 Leaders shouldn't keep themselves aloof from the masses. 领导人决不应该脱离群众。 Keep calm!安静! You shouldn't keep chopping and changing like this; you'd better make up your mind right now! "你不能再这样变化无常了,最好现在就拿定主意!" 遵守 He keeps to his promise.他守约。 "Everyone should keep discipline, and you, officers are no exception." "每个人都应该遵守纪律,你们军官也不例外。" 保卫;保护 Keep the baby warm.别把婴儿冻着。(常与from连用)防止;抑制 Keep one's temper。抑制住不发脾气。 Keep a curb on your anger.请抑制住怒气。 扣留;留下 Please keep me a place in the queue.请在队里给我留个位置。 赡养;饲养 to keep a dog养狗 Farmers usually keep chickens in their backyard. 农民们通常在自己的后院养鸡。 经营;经销;管理 to keep a shop开商店 to keep house治家 (常与from连用)远离;不接触 Keep away from the scene of the accident.勿靠近事故现场。 Their dog looked dangerous, we decided to keep our distance from it. 他们家那条狗样子很凶恶,因此我们决定离它远一点。 But the stone walls keep the farmer's cows from joining his neighbor's cows. 但是石头墙使这家农民的母牛不会加入到邻居的牛群中去。

不定代词和动词不定式用法小结

不定代词的用法 1.代替或修饰不特指的人或事物的代词叫不定代词 2.some与any的区别 1)some多用于肯定句,表示“一些,几个”,可修饰不可数名词和可数名词的复数形式。any 多用于疑问句、条件句和否定句中,表示“一些”,可修饰不可数名词和可数名词的复数形式 2)在反问句、疑问句中,表示请求、建议和希望对方得到肯定回答时,多用some. Would you like some beer?你要不要来点啤酒吗? Why didn’t you buy some sweets?你怎么没买点糖果? 3)any 用于肯定句时,表示是“任何的” Come any day you like.你哪天来都行。 3)some还有表示“某个”的意思 I’ll catch up with you some day有一天我会赶上你的。 3.复合不定代词:something(某事), someone(某人), somebody(某人), anything(任何事), anyone(任何人), anybody(任何人), nothing(没事),nobody(没有人), no one(没有人), everything(一切), everyone(每个人), everybody(每个人). A:作主语时,谓语动词用单数。Is there anything wrong with your watch?”“No, nothing is wrong with it B:修饰复合不定代词的形容词或不定式一定要位于它们的后面。 This is something special. 这是种特别的东西。 Haven’t you got anything to do? 你无事可干吗? C:一般来说,当主语是指人的复合代词,如everybody, nobody, anybody 等时,其反意疑问句后面的主语通常用代词they;当前面句子中的复合代词指物,如everything, something, anything, nothing 等时,其反意疑问句后面的主语通常用代词it。如:Everyone is here, aren’t they? 人都到了,是吗? Everything is ready, isn’t it? 一切准备好了,是吗? Somebody is waiting for me at the gate, aren’t they? 有人在门口等我,是吗? 3.few, a few, little, a little在用法上的区别 1)few、little意思是“很少几个”、“几乎没有”,有否定的意思,a few、a little意思是“有几个”、“有些”,有肯定的意思;few、a few修饰可数名词或代替可数的事物, little、a little修饰不可数名词连用或代替不可数的事物。 He is very poor and he has little money. 他很穷,几乎没有什么钱 Don’t worry. There is st ill a little time left. 别着急,还有一点儿时间呢 In that polar region there live few people. 在那个极地地区几乎不住人 You can get a few sweets from him. 你可以从他那儿弄到一些糖果 2)a little和little也可以用作副词,a little表示“有点,稍微”,little表示“很少”。 I'm a little hungry. Let him sleep a little. 3)quite a few (相当多)only a few (只有几个,几乎没有) 4、all和both, either的用法 1)all 指三者或三者以上的人或物,用来代替或修饰可数名词或不可数名词。both指两个人或物,用来代替或修饰可数名词 All the food is delicious.所有的食物都很好吃。 Her parents are both doctors.她父母都是医生

倒装用法归纳(部分-全部)

Unit5 Grammar Inversion(倒装) 英语部分倒装用法归纳(Partial Inversion) 1. 否定副词位于句首时的倒装 在正式文体中,never, seldom, rarely, little, hardly, scarcely, no sooner, no longer, nowhere 等含有否定意义的副词若位于句首,则其后要用部分倒装: I shall never forgive him. / Never shall I forgive him. 我永远不会宽恕他。 He seldom goes out for dinner. / Seldom does he go out for dinner. 他很少出去吃饭。 She hardly has time to listen to music. / Hardly does she have time to listen to music. 她几乎没时间听音乐。 He little realizes how important this meeting is. / Little does he realize how important this meeting is. 他不甚明白这个会议的重要性。 We had no sooner reached the airport than the plane took off. / No sooner had we reached the airport than the plane took off. 我们刚到机场,飞机就起飞了。 【注意】 (1)对于not…until句型,当not until…位于句首时,其后的主句要用倒装语序: He didn’t leave the r oom until the rain stopped. / Not until the rain stopped did he leave the room. 雨停了之后他才离开这房间。 (2)某些起副词作用的介词短语,由于含有否定词,若位于句首,其后要用部分倒装: On no accounts must this switch be touched. 这个开关是绝不能触摸的。 In [Under] no circumstances will I lend money to him.无论如何我也不会再借钱给他了。 但是,in no time(立即,马上)位于句首时,其后无需用倒装语序: In no time he worked out the problem. 他马上就算出了那道题。 2.“only+状语”位于句首时的倒装 当一个状语受副词only的修饰且置于句首时,其后用部分倒装语序: Only then did he realize that he was wrong. 到那时他才意识到他错了。 Only in this way are you able to do it well. 你只有用这种方法才能把它做好。 Only when he returned home did he realize what had happened. 当他回到家里时,才知道出了什么事。 3. “so+adj. / adv.”位于句首时的倒装 副词so后接形容词或副词位于句首时,其后用部分倒装: So cold was the weather that we had to stay at home. 天气太冷,我们只好呆在家里。 So fast does light travel that we can hardly imagine its speed. 光速很快,我们几乎没法想像它的速度。 So sudden was the attack that we had no time to escape. 袭击来得非常突然,我们来不及逃跑。 4.“so+助动词+主语”倒装 当要表示前面提出的某一肯定的情况也同样适合于后者,通常就要用“So+助动词+主语”这种倒装结构: You are young and so am I. 你年轻,我也年轻。 She likes music and so do I. 她喜欢音乐,我也喜欢。

java static 的使用方法

类方法 方法被声明为static后,则称为类方法。类方法相对于实例方法,前者区别于后者的地方:前者为属于该类的所有实例对象共享,无须实例化对象,仅通过类名即可访问(当然,是否能够直接访问,还取决于所声明的访问权限)。 因为被static化后产生上述特殊性,所以static变量都会在类被加载时初始化,而类方法也同时随类加载而进驻内存。先来段代码热热身吧~ 上段代码,输出结果为: null A Class 由结果可知,即字符串prvateStr的值为空。嘿,可别认为值应该是下面那样啊。那样 的话,进行下去就太具挑战性了。 A Class A Class 请记住一点,类变量初始化的顺序与其在类中的赋值顺序一致。

重写(覆盖) 或许大家对于面向对象编程语言最初的印象就是其语言单元是以父类、子类的关系存在着,而构建这一关系的就是继承机制了。子类可以继承父类一切非private的变量与方法,并且可以添加自己的变量与方法。在构建一个系统时,这机制让我们强烈地感觉到编程是一 门优雅的艺术。 来段小小的代码简单地展示下: 结果如下: Jack I am a thinking animal, and a Programmer

如上,子类Programmer中并没定义字符串characteristic,但我们却在其方法printProfession()中调用了;同样,我们正常使用了父类定义的printName()方法。而这就 是继承的简单实现。 继承不仅仅带来以上特性。它还赋予子类重写(覆盖)父类方法的能力(因为旨在讲类方法的重写,所以这儿就不讲重载以及变量在继承机制中的问题了)。方法的重写(覆盖):继承父类的子类,可以通过拟具有相同方法名与参数组的方法来重写父类中对应的方法,从而让子类更个性化。又因为重写(覆盖)的出现,多态也随之产生。多态:通过父类变量可以引用其子类对象,从而调用子类中那些继承自自己并被重写(覆盖)的方法。

不定式的特殊用法小结

不定时的用法 to do 的其它用法: 1. 时态和语态形式to do/to be done/to be doing/to have done/to have been done/to have been doing (1) 一般式表动作通常与谓语动词所表动作同时或在其后发生; 进行式表动作与谓语动作同 时进行;完成式表动作发生在谓语动作之前; pretend / believe /say/seem/happen/prove/plan/hope/expect/should like/would like + to have done 表未曾实现的行为; 完成进行式表动作在谓语动作之前已开始并一直进行着,到说话时为止,该动作可能停止,也可能还在继续。 People began to wonder how long the disaster would last. The children pretended to be reading aloud when the teacher came in. I didn’t expect you to be waiting for me so long. The crowd cheered wildly at the sight of Liu Xiang, who was reported to have broken. the world record in the 110- metre hurdle race. He’s said to have written a new novel. I would like to have had your help. I hoped to have seen her . He planned to have gone abroad. He was said to have been living in New York for twenty years. (1)主动式表逻辑主语为不定式动作的执行者;被动式表逻辑主语是不定式动作的承受者。 I hope to finish reading the book tonight. We are invited to a party to be held in our club next Friday. 2.to do 的主动表被动 (1)to do 作定语与被修饰词构成动宾关系,同时又和句子主语构成主谓关系。 I have a lot of papers to deal with. (2) be + 性质adj. + to do . easy/hard/difficult/interesting/heave/pleasant/comfortable/safe/dangerous/impossible Tom is pleasant to work with. This book is difficult to understand. I like getting up very early in summer. The morning air is so good to breathe. (2)be + let /blame/ seek It seemed that water was to blame. The cause isn’t far to seek. The house is to let. (3)wh- + to do I had no idea who to turn to for help the time I lost. How to divide labor among them is still a question. (5) there be + 主语+ to do 中,当强调某人完成某事时用主动形式;当强调某事必须被完成用被动形式。 There’s many work to do. (sb. has to do the work. )/ to be done.(the work has to be done.) 3.to do 的逻辑主语是其所表动作的承受者时用被动。 It’ an honor for me to be invited to the party. The books and mag azines aren’t allowed to be taken out of the reading room. I wanted the letter to be typed at once She asked to be assigned to do a heavy job. 4.如果逻辑主语没出现,只要意义是被动的,to do仍用被动。 It’s great honor to be elected a delegate to the Party. To be attacke d by the enemy isn’t a bad thing but a good thing. 5.to do中动词的省略,只保留to . (1)to do作某些动词的宾语时:当作宾语的不定式再次出现时,为避免重复,只留to. afford/ agree/ expect/ forget/ hate/ hope/ intend/ mean/ plan/ prefer/ refuse/ try/ want/ wish/ would like/ love/ care

keep的用法

1.keep +形容词 2.keep+sth/sb +形容词 3.keep +doing 一直做某事 4.keep ... from doing ... 阻止做某事。。。 5.keep a pet 饲养一个宠物 6.How long may I keep this book ? keep指借。 keep的用法小结 keep是高考常考词汇之一,其含义丰富,与其搭配的短语也很多,其主要用法如下: A、用作及物动词 (1)保留、保存、保持、留下 e.g. We'd better keep a seat for him. 我们最好给他留个座位。 He kept all the money in the bank. 他把所有的钱都存入了银行。 (2)履行(诺言)遵守 e.g. One should keep one's promise. 一个人应当遵守自己的诺言。 Everybody must keep the law. 人人都必须守法。 (3)赡养,养活,饲养 e.g. He has a large family to keep. 他有一大家人要养活。 The old man kept many animals like dogs, pigs and cats. 这位老人养了许多动物,像狗、猪、还有猫等。 (4)经营,管理

e.g. He kept a hotel in this city. 在这座城市里,他开了一家旅店。 She is good at keeping house. 她擅长管理家务。 (5)保守(秘密),记(日记、帐) e.g. All of the people keep the Spring Festival in our country. 我国所有的人都庆祝春节。 Some of them keep birthdays. 他们中有些人庆祝生日。 (7)使……处于某种状态(情况) 在这种情况下,keep常跟复合结构(keep+宾语+补语)。用作宾语补足语常见的词有现在分词、过去分词、形容词、副词以及介词短语。 e.g. He kept me waiting for half an hour. 他让我等了半个小时。 Keep your mouth shut and your eyes open. 少说话,多观察。 The doctor kept me in for a week. 医生一周没让我出去。 He always keeps his books in good order. 他总是把书放得整整齐齐。 B、用作不及物动词 (1)保持、继续(处于某种状态)(keep为连系动词)

英语动词不定式的完成式用法小结

英语动词不定式完成式在使用语境中的学习与考查 江苏省沛县湖西中学鹿俊先221611 综观近年的英语高考试题,我们可以看到题目的设置往往强调语言知识在特定语境中的使用,把语言知识放在了语用层面上,即考察实际应用知识的能力。 英语动词不定式的完成式,即(to) have +动词的过去分词形式,是中学英语学习中的重点及难点知识之一,也是高考试题中频繁出现的形式。对于这一形式考查的题目设置通常围绕三类语境,即陈述已经发生过了的事实,推测可能已经发生过了的事实,表达与过去实际情况相反的事实。下面分别加以叙述,以便从语用角度掌握这一语言知识。 1.陈述已经发生过了的事实。 1.1.置于表示情感反应的动词、形容词、分词之后,作为引起该反应的刺激,表示情感反应之前完成的动作。例如: I'm sorry to have given you so much trouble. (=I'm sorry that I gave / have given you so much trouble.) It is good to have finished work for the day. (=I am pleased because I have finished.) She said she was sorry to have missed you. (=She said she was sorry that he had missed you.) There was a smile on the boy's face, which seemed to show that he was happy to have given his life to his country. (=…he was happy that he had given his life to his country.) 1.2.置于be said, be considered, be believed, seem, appear, happen, turn out,等之后表示这些动作之前完成的动作。例如: I don't know whether you happen to have heard, but I am going to study in the U.S.A. this September. Charles Babbage is generally considered to have invented the first computer. (=It is generally considered that Charles Babbage invented the first computer.) He is said to have studied abroad, but I don't know which country he studied in. (= It is said that he studied abroad, b ut….) I appear to have made a small mistake. (=It appears that I made / have made a small mistake.) He seems to have missed the train. (=It seems that he missed the train.) 1.3.置于should之后,表达说话人对已发生了的事实的情感的反应,如惊奇、遗憾、喜悦、不安、失望,等,should相当于汉语中的“竟然”,“居然”。例如:They were surprised (that) a child should have worked out the problem while they themselves couldn't. It is strange that she should have married such an old man. 2.推测可能已经发生过了的事实。 2.1.置于must, will, would, can't, couldn't 之后,表示很有把握的推论。例如: The city must have been prosperous, for it enjoyed a high level of civilization. An ambulance is waiting in the street. Somebody must have been hurt or killed. --I met her soon after the war.

be+不定式的用法小结

be+不定式的用法小结 be+不定式是英语中常见的一种结构,关于它的用法现在总结如下: 一、构成系表结构: 1、表示目的,例如: The prize was to honour him for his great discoveries. 这项奖励是为了对他的重大发现而表示的敬意。 2、对主语内容进行解释说明,例如: What you should do is (to) answer my questions. 你所应该做的就是回答我的问题。 二、表示将来: 1、表示按计划安排要发生的事情,例如: The president is to visit China next year. 总统将于明年访问中国。 If we are to be there in time, we'll have to hurry up. 如果我们想及时到达那里,就必须要赶快。 注:我们可以说:It's going to rain. 但不能说:It's to rain. 2、表示无法预见的结果或注定要发生的事情,例如: Better days are soon to follow. 好日子就要到了。 三、构成虚拟语气: 1、were to do 用于虚拟条件句中,表示对将来情况的虚拟。例如:What would you do if war were to break out? 假如战争爆发你会怎么做?

2、was/were+不定式的完成式(=should+不定式的完成式)表示过去应该发生而未发生的动作,例如:We were to have been married last year。 我们本打算去年结婚的。 四、be 后的个别动词不定式的主动形式表示被动意义,例如: It's Jim who is to blame. 该怪的是吉姆。 This house is to let. 此房出租。 五、其他用法: 1、表示命令,指令。例如: You are not to bring any mobile communication means into the exam-room. 任何移动通讯工具都不得带入考场。 2、表示必须,必要。例如: This letter is to be handed to him in person. 这封信必须要面交他本人。 3、表示能够或可能发生的事情,例如: How are we to convince him? 我们怎么能够说服他呢? 4、表示应该,例如: Such questions are to be avoided. 这样的问题应该避免。

keep的用法

用作动词(v.) keep about〔around〕1( v.+adv. ) 1. 继续履行职责go on with one's duties keep about〔around〕 She is very ill, but she still keeps about. 她虽然病得很重,但仍然继续工作。 2. 使手边常有have sth always present keep sth ? about〔around〕 I like to keep a few envelopes around in case I need them.我喜欢手边常有几个信封,以应不时之需。 keep about〔around〕2 ( v.+prep. ) keep abreast of( v.+adv.+prep. ) keep after( v.+prep. ) keep aloof( v.+adv. )

keep apart( v.+adv. ) keep at( v.+prep. ) keep away( v.+adv. ) keep away from( v.+adv.+prep. ) keep back( v.+adv. ) keep behind1( v.+adv. ) keep behind2 ( v.+prep. ) keep by1( v.+adv. ) keep by2( v.+prep. ) keep down( v.+adv. ) keep for( v.+prep. ) keep from( v.+prep. ) keep going( v.+adj. ) keep in1( v.+adv. ) keep in2( v.+prep. )

动词不定式用法经典例句总结知识分享

动词不定式用法例句总结

定义 (语态)动词和参与此动作的主语之间关系的一个术语。当主语是动作的发起者(或之一)时,称为主动语 态; 如果动词不定式的逻辑主语是这个不定式所表示的动作的承受者,不定式一般要用被动语态形式。如:It's a great honour to be invited to Mary's birthday party. (不定式作主语是被动语态to be invited 是被邀请)It was impossible for lost time to be made up. (不定式作主语) I wish to be sent to work in the country. (不定式作宾语) Can you tell me which is the car to be repaired? (不定式作定语) He went to the hospital to be exam in ed. (不定式作状语) My work is to clea n the room every day. (不定式作表语) 在There be 结构中,修饰主语的不定式可用被动,也可用主动。如:There are still many things to take care of (to be taken care of). 但有时两种形式表达的意思不同,如:There is noth ing to do now.( We have nothi ng to do no w.) There is nothing to be done no w.(We can do nothing no w.) 形式 1)现在式:一般现在时表示的动词,有时与谓语动词表示的动作同时发生,有时发生在谓语动词的动作之 后。一般为:动词+ to do sth He seems to know this. I hope to see you aga in. = I hope that r II see you aga in. 我希望再见至M尔。 2)完成式:表示的动作发生在谓语动词表示的动作之前。 rm sorry to have give n you so much trouble. He seems to have caught a cold. 3)进行式:表示动作正在进行,与谓语动词表示的动作同时发生。 He seems to be eat ing someth ing. 4)完成进行式: She is known to have been wreaking on the problem for many years. 一般在表示情绪的动词后加to do也表将来 疑问词 疑问词who,what,which,when,where,whether,how 语等。如: ①W hen to leave for London has not bee n decided yet. ② Mr. Smith did n't know whether to leave or stay there. ③ I asked Professor Xu how to lear n En glish well. ④The questi on was where to get the medici ne n eeded. 以上例句中疑问词+不定式部分,均可转换为相应的 could lear n ......... 后可接不定式构成不定式短语,在句中作主语、宾语、表 (不定式在句子中做主语) (不定式在句子中做宾语) (不定式在句子中做直接宾语) (不定式在句子中表语) 从句形式。如:①When we shall leave …③? -how I

英语-倒装句用法精编版

倒装句用法总结归纳 一、部分倒装: 1.否定副词位于句首时的倒装 在正式文体中,never, seldom, rarely, little, hardly, scarcely, no sooner, no longer, nowhere 等含有否定意义的副词若位于句首,则其后要用部分倒装: I shall never forgive him. / Never shall I forgive him. 我永远不会宽恕他。 He seldom goes out for dinner. / Seldom does he go out for dinner. 他很少出去吃饭。 He little realizes how important this meeting is. / Little does he realize how important this meeting is. 他不甚明白这个会议的重要性。 注意: (1) 对于not…until句型,当not until…位于句首时,其后的主句要用倒装语序: He didn’t leave the room until the rain stopped. / Not until the rain stopped did he leave the room. 雨停了之后他才离开这房间。 (2) 某些起副词作用的介词短语,由于含有否定词,若位于句首,其后要用部分倒装: On no accounts must this switch be touched. 这个开关是绝不能触摸的。 (3) 但是,in no time(立即,马上)位于句首时,其后无需用倒装语序: In no time he worked out the problem. 他马上就算出了那道题。 2.“only+状语”位于句首时的倒装 当一个状语受副词only的修饰且置于句首时,其后用部分倒装语序: Only then did he realize that he was wrong. 到那时他才意识到他错了。 Only in this way are you able to do it well. 你只有用这种方法才能把它做好。 3.“so+adj. / adv.”位于句首时的倒装 副词so后接形容词或副词位于句首时,其后用部分倒装: So cold was the weather that we had to stay at home. 天气太冷,我们只好呆在家里。 So sudden was the attack that we had no time to escape. 袭击来得非常突然,我们来不及逃跑。 4.“so+助动词+主语”倒装 当要表示前面提出的某一肯定的情况也同样适合于后者,通常就要用“So+助动词+主语”这种倒装结构: You are young and so am I. 你年轻,我也年轻。 If he can do it, so can I. 要是他能做此事,我也能。 注意: (1) 若前面提出某一否定的情况,要表示后者也属于同样的否定情况,则应将其中的so改为neither或nor: You aren’t young and neither am I. 你不年轻,我也不年轻。 She hasn’t read it and nor have I. 她没有读它,我也没有读。 (2) 注意该结构与表示强调或同意的“so+主语+特殊动词”结构的区别: "It was cold yesterday." "So it was." “昨天很冷。”“的确很冷。” "Father, you promised." "Well, so I did." “爸爸,你答应过的。”“嗯,是答应过。”

java中如何使用Static的变量和方法

如何使用Static的变量和方法 有时你希望定义一个类成员,使它的使用完全独立于该类的任何对象。通常情况下,类成员必须通过它的类的对象访问,但是可以创建这样一个成员,它能够被它自己使用,而不必引用特定的实例。在成员的声明前面加上关键字static(静态的)就能创建这样的成员。如果一个成员被声明为static,它就能够在它的类的任何对象创建之前被访问,而不必引用任何对象。你可以将方法和变量都声明为static。static 成员的最常见的例子是main( ) 。因为在程序开始执行时必须调用main() ,所以它被声明为static。 声明为static的变量实质上就是全局变量。当声明一个对象时,并不产生static变量的拷贝,而是该类所有的实例变量共用同一个static变量。声明为static的方法有以下几条限制: 1.它们仅能调用其他的static 方法。 2.它们只能访问static数据。 它们不能以任何方式引用this 或super(关键字super 与继承有关)。 如果你需要通过计算来初始化你的static变量,你可以声明一个static块,Static 块仅在该类被加载时执行一次。下面的例子显示的类有一个static方法,一些static变量,以及一个static 初始化块: // Demonstrate static variables,methods,and blocks. class UseStatic { static int a = 3; static int b; static void meth(int x) { System.out.println("x = " + x); System.out.println("a = " + a); System.out.println("b = " + b); } static { System.out.println("Static block initialized."); b = a * 4; } public static void main(String args[]) { meth(42); } } 一旦UseStatic 类被装载,所有的static语句被运行。首先,a被设置为3,接着static 块执行(打印一条消息),最后,b被初始化为a*4 或12。然后调用main(),main() 调用meth() ,把值42传递给x。3个println ( ) 语句引用两个static变量a和b,以及局部变量x 。 注意:在一个static 方法中引用任何实例变量都是非法的。 下面是该程序的输出: Static block initialized. x = 42 a = 3 b = 12

小学英语不定式用法总结

不定式作主语 1)It's easy (for me) to do that.我做这事太容易了 easy, difficult, hard, important, possible, impossible, comfortable, necessary, better; the first, the next, the last, the best, too much, too little, not enough It's so nice to hear your voice. 听到你的声音真高兴。 It's necessary for you to lock the car when you do not use it. 当你不用车的时候,锁车是有必要的。 2) It's very kind of you to help us. 他帮助我们,他真好。 Kind, nice, stupid, rude, clever, foolish, thoughtful, thoughtless, brave, considerate(考虑周到的), silly, selfish(自私的) 例句: It was silly of us to believe him. 我们真愚蠢,竟然相信了他。 It seemed selfish of him not to give them anything. 他不给他们任何东西,这显得太自私了。 注意:1) 其他系动词如,look,appear等也可用于此句型 2) 不定式作为句子成分时,动词用单数形式。 3) 当不定式作主语的句子中又有一个不定式作表语时,不能用It is… to…的句型 (对)To see is to believe. 百闻不如一见。

Keep_用法

Keep 用法知多少 keep 是英语中用法灵活的动词之一,用法归纳如下: 一、用作系动词,意为“保持(某种状态)”,其后常接形容词作表语。如: Please keep quiet / silent! 请保持安静! After the accident, he still kept alive. 这次事故之后,他仍然活着。 二、用作实义动词,可表示: 1. 保管;保存;保留。如: Keep the change. 零钱不用找了。 Please keep these things for me while I am away. 在我离开期间,请你替我保管这些东西。 2. 赡养;饲养。如: Does he earn enough to keep himself and his family? 他的收入够养活他自己和他的家人吗? I used to keep sheep in my childhood. 我在孩提时常常养羊。 3. 经营。如: Her father kept a grocer's shop for a number of years. 她父亲开了几年杂货店。 4. 坚持;继续。后面如接动词,要用V-ing 形式作宾语。如: If you keep (on) practising your spoken English, you'll soon make great progress. 如果你坚持练习英语口语,你很快就会取得很大的进步。 5. 阻止;阻碍。常用于keep sb/sth from doing sth 结构中,其中介词from 不能省略。如: The heavy rain didn't keep them from watching the football match. 大雨没能阻止他们观看足球赛。 6. 保持。其后常接复合宾语,表示使(某人或某物)保持某种状态或使某一动作继续。 ①keep + sb/sth + 介词。如:

相关文档
相关文档 最新文档