-
-
4
-
2#include <iostream> #include <graphics.h> #include <string> #include <stdlib.h> #include <conio.h> using namespace std; #define RATIO 61 #define SCREEN_WIDTH 960 #define SCREEN_HEIGH 768 #define KEY_UP 'w' #define KEY_LEFT 'a' #define KEY_RIGHT 'd' #define KEY_DOWN 's' #define KEY_QUIT 'q' #define START_X 100 #define START_Y 150 #define MAP_X 9 #define MAP_Y 12 enum _PROPS{ WALL, //墙 FLOOR, //地板 B0X_DES, //箱子目的地 MAN, //人 BOX, //箱子 HIT, //箱子命中目标 ALL }; enum _DIRECTION{ UP, DOWN, LEFT, RIGHT }
-
4void yue1(){ Girl *p=new Girl("如花") delete p; } 这里删除p时会调用析构函数,析构函数本来就是起删除作用,这里又delete不是多余的吗?析构函数不是在一个类结束后自动调用吗?
-
2Colonnello可乐尼洛同学的问题贴:
-
2
-
2请问在函数前加::(没有类和名称空间)有什么用?
-
2#include <graphics.h> #include <conio.h> #include <thread> using namespace std; IMAGE pic; char direction; int x = 200, y = 200; void init() { initgraph(600, 600); setbkcolor(WHITE); cleardevice(); loadimage(&pic, "man.bmp"); putimage(200,200,&pic); } void threadMove() { int v = 2; while (1) { switch (direction) { case 'w': y -= v; break; case 's': y += v; break; case 'a': x -= v; break; case 'd': x += v; break; default: break; } } if (x <= 0) { x = 0; } else if (x>=600-61) { x = 600 - 61; } if (y<=0) { y = 0; } else
-
4
-
1
-
2
-
3
-
1
-
1
-
1输入层数,回车后全空格 #include<stdio.h> int show_pytamid(char c,int layer){ int i; int j; if (layer < 1){ printf("金字塔层数必须大于0\n"); return; } if (c ==' ' || c == '\n' || c == '\t'){ printf("非法金字塔字符\n"); return; } for (i=1;i<=layer;i++){ for (j=0; j<layer-i;j++){ printf(" "); } for (i=0;j<i*2-1;j++){ printf("%c",c); } printf("\n"); } } int main(void){ char c; int n; printf("请输入金字塔的字符:"); scanf("%c",&c); printf("请输入金字塔的层数
-
3以下是源代码: #include <Windows.h> #include <string> #include <iostream> #include "hacker.h" using namespace std; #define WIDTH 50 #define HEIGHT 30 void init(void){ //mode con cols = 50 lines = 25 char cmd[128]; sprintf(cmd,"mode con cols=%d lines=%d",WIDTH,HEIGHT); system("cmd"); } void printInMiddle(string msg){ int space = (WIDTH - msg.length())/2; for (int i=0; i<space; i++){ cout << " "; } cout << msg << endl; } void login(void){ string name; string pwd; while(true){ system("cls"); cout <&l
-
1
-
3
-
4
-
1
-
2想问一下iomanip头文件里面的setw函数怎么使用,博客上面看不懂
-
2
-
2set容器,存储自定义类的时候,要重载比较运算符,但是假如存储的是类的指针,就不用,他是默认的比较地址大小还是?
-
1
-
1
-
1
-
0
-
1没有报错 编译成功 可运行 输入用户名和密码之后程序崩溃,求各路大神指点 #include <stdio.h> #include <string.h> #include <stdlib.h> //全局变量 FILE*file; //初始化 void init(void){ //打开文件 file = fopen("mima.txt","r"); if (!file){//等效于file == NULL printf("文件打开失败"); //return 1; exit(1); } } void login(void){ char name[32];//用户名 char pwd[16];//密码 FILE*file; char line[128]; char name_tmp[32]; char pwd_tmp[16]; char *ret; //输入用户名和密码 while(1){ system("cls"
-
5
-
4Computer.h代码如下: #pragma once #include <string> class ComputerService; #include "ComputerService.h"; using namespace std; class Computer { public: Computer(); string getCpu(); friend void ComputerService::upgrade(Computer* computer); private: string cpu; }; Computer.cpp代码如下: #include "Computer.h" Computer::Computer() { this->cpu = "i7"; } string Computer::getCpu() { return cpu; } ComputerService.h代码如下: #pragma once #include "Computer.h" class Computer; class ComputerService { public: void upgrade(Computer* computer); };
-
1
-
2
-
1
-
2
-
1Car类: Car(); Car(const string& carBrand, const string& carVersion, int price, const string& engineBrand, float engineVersion, const string& tireBrand="米其林"); ~Car(); Car::Car() { } Car::Car(const string& carBrand, const string& carVersion, int price, const string& engineBrand, float engineVersion, const string& tireBrand) : engine(engineBrand, engineVersion), tires{ tireBrand,tireBrand ,tireBrand ,tireBrand } { this->brand = carBrand; this->version = carVersion; this->price = price; this->miles = 0; } Tire类: Tire(); Tire(cons
-
1
-
4
-
2
-
7