c_cpp

Similar documents
FY.DOC

新版 明解C++入門編

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

C/C++程序设计 - 字符串与格式化输入/输出

CC213

untitled

C/C++语言 - C/C++数据

untitled

第七讲 继承与多态

C++ 程式設計

第3章.doc

untitled

Microsoft Word - CPE考生使用手冊 docx

新・明解C言語入門編『索引』

untitled

untitled

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1

untitled

C/C++ - 文件IO

untitled

nooog

Chapter12 Derived Classes

提问袁小兵:

C/C++ - 数组与指针

51 C 51 isp 10 C PCB C C C C KEIL

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

C C

(6) 要 求 付 款 管 理 员 从 预 订 表 中 查 询 距 预 订 的 会 议 时 间 两 周 内 的 预 定, 根 据 客 户 记 录 给 满 足 条 件 的 客 户 发 送 支 付 余 款 要 求 (7) 支 付 余 款 管 理 员 收 到 客 户 余 款 支 付 的 通 知 后, 检

Microsoft Word - 2CA13內文.doc

Microsoft Word - ch04三校.doc

Strings

5. 閱 讀 下 文, 推 斷 內 最 適 合 填 入 的 詞 語 依 序 為 何? 人 也 真 是 一 個 絕 字, 一 邊 向 左, 一 邊 向 右, 一 副 的 樣 子, 偏 又 相 連 著, 各 說 各 話 各 走 各 路, 卻 又 人, 這 麼 一 個 簡 單 的 字, 竟 包 含 如 此

Microsoft Word - 01.DOC

Microsoft Word - 物件導向編程精要.doc

Strings

Ps22Pdf


C++ 程序设计 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1

Microsoft Word cppFinalSolution.doc

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

概述

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

文档 3

Microsoft PowerPoint - plan08.ppt

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C Project 30 C Project 3 60 Project 40

<4D F736F F F696E74202D20332D322E432B2BC3E6CFF2B6D4CFF3B3CCD0F2C9E8BCC6A1AAD6D8D4D8A1A2BCCCB3D0A1A2B6E0CCACBACDBEDBBACF2E707074>

ebook39-5

Microsoft PowerPoint - L17_Inheritance_v4.pptx

全国计算机技术与软件专业技术资格(水平)考试

_汪_文前新ok[3.1].doc

立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

chap07.key

C/C++ 语言 - 循环

用户大会 论文集2.2.doc

untitled

Microsoft PowerPoint - 10 模板 Template.pptx

目录

C 1

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2

Microsoft Word - chap10.doc

untitled

华恒家庭网关方案

《晚年周恩来》目录

Ps22Pdf

EJB-Programming-3.PDF

保母人員丙級應檢資料第二部份 doc

第2章 递归与分治策略

学习MSP430单片机推荐参考书


<4D F736F F D20B2C43032B3B920B8EAAEC6ABACBA41BB50AAEDA5DCA6A12E646F63>


C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha

untitled

Ps22Pdf

C/C++语言 - 分支结构

《C语言程序设计》教材习题参考答案

運算子多載 Operator Overloading

使 用 Java 语 言 模 拟 保 险 箱 容 量 门 板 厚 度 箱 体 厚 度 属 性 锁 具 类 型 开 保 险 箱 关 保 险 箱 动 作 存 取 款

建协质(2005)20号

PowerPoint 簡報

<4D F736F F D20AC4FBDBDA4FBB67DA96CAABA2DA743A67EAFC5AAA95FA7B9BD5A5F2E646F63>

ex

PowerPoint 演示文稿

2015年计算机二级(C语言)模拟试题及答案(四)

Chapter 9: Objects and Classes

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc

EK-STM32F

untitled

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

( 总 第 1073 期 ) 浙 江 省 人 民 政 府 主 办 2015 年 3 月 17 日 出 版 省 政 府 令 省 政 府 文 件 目 录 浙 江 省 大 型 群 众 性 活 动 安 全 管 理 办 法 ( 浙 江 省 人 民 政 府 令 第 333 号 ) (3) 浙 江 省 人 民 政


(E — F)

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii

中華民國第 54 屆中小學科學展覽會

Transcription:

C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i<max; i++) string[i]=string2[i]; : c=a+b; int x; x=a-b; 1

C++ cout cin C++ #include <iostream> C printf scanf #include <stdio.h> C++ #include <stdio.h> printf scanf C++ : cout C++ cout cout << << cout << value ; cout << x; cout << Value <<x; cout << Value << x << \n ; cout << Value << x << \n ; cout << Value <<xx <<endl // endl 2

C++ : cin C++ cin cin >> >> cin >> answer; cin.getline(, ) cin.getline(str,80) ch=cin.get(); Namespace Namespace using C++ std namespace #include <iostream> using namespace std; 3

cin cout C C++ int, float, double, char signed, unsigned, long, short, const, volitale, static, register, extern C++ public, private, protected, friend, inline, virtual unsigned a unsigned int a short a short int a; long a long int a; 4

:: C (global variable) (local variable) C++ :: :: C++ :: :: :: ex1_1 int i=10; void main(){ int i=20; { cout<<"the inner block\n"; int n=i++; int i=30; ::i++; cout << i= <<i<< ::i= <<::i<<endl; cout << n= <<n<<endl; cout <<"The outer block\n"; cout << i= <<i<< ::i= <<::i<<endl; 5

: const const #define #define const const 1. 2. 3. : const float pi=3.14159; // #define pi 3.14159 // const int *p; (*p)++; : void a (const int *p) 6

( ) C++ (reference) type & identifier1=identifier2; identifier1 identifier2 : int a,b; int &alt=a; // alt a alt=b; // a=b alt++; // a++ ( ) int a; int *point=&a; *point=a point=&a *point++; // a++ a++; // *point++; 7

char & refchar= \0 ; char temp= \0 ; char &refchar=temp; C (call by value) C & * C++ 8

: ex1_2 void Swap(int *p, int *q){ int temp; temp=*p; *p=*q; *q=temp; void main(){ int a,b; cout << a= ; cin >> a; cout << b= ; cin >> b; Swap(&a,&b); cout << a= <<a<<endl; cout << b= <<b<<endl; : ex1_3 void Swap(int &p, int &q){ int temp; temp=p; p=q; q=temp; cout << a= ; cin >> a; cout << b= ; cin >> b; Swap(a,b); cout << a= <<a<<endl; cout << b= <<b<<endl; void main(){ int a,b; 9

C++ : void abc(float k, int j, int i=5) // void xyz(float k=1,int j, int i) // void err_use(float k, int j=2, int i) // abc(5,3) abc(2,4,1) ex1_4 int add(int i,int j=1){ return(i+j); void main(){ int a; cout <<"a="; cin >> a; cout << add(a,2) << endl; //, a 2 cout << add(a) << endl; // 1, a 1 ( ) 10

inline C/C++ #define : #define sq(x) x*x #define C/C++ :(ex1_5) #define sq(x) x*x void main(){ int y=5; cout <<sq(y)<< \n ; // 25 cout <<sq(y+1)<< \n ; // 11, 5*1+5*1=11 inline #define C++ inline inline ( ) { // C++ inline inline : : 11

inline ex1_6 inline int SQ(int x){return (x*x); void main(){ int a=5,b=3; cout << SQ(a-b)= <<SQ(a-b); SQ(a-b)=4 C malloc, calloc, realloc( ), free #include <alloc.h> C++ new delete 12

new new : : = new ; float *buf; buf=new float; // 1 : = new [ ] ; int *p; p=new int[20]; // 20 delete delete new : : delete ; float *buf; buf=new float; // 1 : delete [] ; int *p; p=new int[20]; // 20 13

new malloc malloc new ( int, char, double, float) malloc free C (constructor ) (destructor) new delete C++ (constructor ) (destructor) new delete new delete ex1_7 #include <alloc.h> class a{ public: a(){ cout << "constructor by new\n ; ~a() {cout << "destructor by delete\n"; ; class b{ public: b(){ cout << "constructor by malloc\n"; ; void main(){ a *p; b *q; p=new a[3]; // 3 a q=(b *)malloc(sizeof(b)); // constructor delete [] p; free(q); constructor by new constructor by new constructor by new destructor by delete destructor by delete destructor by delete 14

C (global variable) (static variable) (local variable) ex1_8 void a(){ static c=0; c++; cout<<c<<endl; void main(){ a(); // 1 a(); // 2 15

C++ struct Stock { char type; double netto; static int count; ; Stock sk1,sk2; sk1.count sk2.count 1.. 2. :: type :: public :: private public 16

( ) a ctest ~ctest(){ 0 constructor 1 destructor 1 (ex1_9) class ctest{ private: static int a; public: ctest(){ a++; a--; void showa(){ cout << a <<endl; ; int ctest::a=0; void main() { ctest c1; c1.showa(); ctest c2; c2.showa(); /* 1 */ /* 2 */ ( ) ex1_10 class ptest{ private: static int a; public: float b; static int d; static void c(){ cout << here ; ; int ptest::d=0; int ptest::a=0; void main(){ ptest p,q; cout<< Size of class ptest= <<sizeof(ptest) << \n ; cout << start address of p= <<&p<< \n ; cout << address of p.b= <<&p.b<< \n ; cout << \ntest of static variable\n ; cout << address of ptest::d << \n ; cout << address of p.d= <<&p.d<< \n ; cout << address of q.d= <<&q.d<< \n ; cout << \nfunction in class\n ; cout << address of function c by &ptest::c= << &ptest::c<< \n ; cout << adress of function c by ptest::c= <<ptest::c<< \n ; cout << address of function p.c= <<p.c<< \n ; 17

cout << address of function q.c= <<q.c<< \n ; Size of class ptest=4 start address of p=0x1a130ffc address of p.b=0x1a130ffc Test of static variable address of ptest::d address of p.d=0x19770094 address of q.d=0x19770094 function in class address of function c by &ptest::c=0x1679026e address of function c by ptest::c=0x1679026e address of function p.c=0x1679026e address of function q.c=0x1679026e 1. 2. this : static ( ) 18

C++ : C (type) expression : y=(double)x; // x double y : type(expression) : y=double(x); // x double y static_cast static_cast<type to convert to>(object to convert) int z = 3; float x = static_cast<int>(z); dynamic_cast 19