C++
失败的Cc
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
c++结构体指针
先上代码 #include<iostream> using namespace std; struct Student1 { int id = 200; int s = 100; char* name = "lisi"; }; void test2() { Student1 *stu = (Student1 *)malloc(sizeof(Student1)); int *var = (int *)stu; cout << "stu->id == " <原创 2021-10-06 10:47:09 · 287 阅读 · 0 评论 -
C++在DOS中实现密码框
#include <iostream> #include <conio.h> using namespace std; int main() { fflush(stdin); cout << "请输入密码:"; int idx = 0; char compare[20], c; while((c = getch()) != 13) { // 13是回车,8是删除 if(c == 8 && idx >原创 2021-09-25 22:14:31 · 302 阅读 · 0 评论 -
C++中创建对象的方式
C++中创建对象的方式 无参数的情况 隐式创建:A a1; 显式创建:A a2 = A(); 通过new关键字创建,返回的是指针:A *a3 = new A(); #include <iostream> using namespace std; class A { public: int id; }; int main() { A a1; a1.id = 1; A a2 = A(); a2.id = 2; A *a3 = ne原创 2021-09-25 17:17:41 · 324 阅读 · 0 评论 -
typedef struct 和 struct在C和C++的区别
typedef struct 和 struct在C和C++的区别 在C++中,下列程序可以直接编译通过,即Student1、Student2、TYPEDEF_STU2都相当于一种类型 #include <stdio.h> struct Student1 { int id; char* name; }; typedef struct Student2 { int id; char* name; }TYPEDEF_STU2; int main() { Student原创 2021-09-25 13:03:53 · 196 阅读 · 0 评论
分享