
C++
liunianwangshui
这个作者很懒,什么都没留下…
展开
-
c++ 将WString转为String时报错
现象:使用vs2019,写c++程序时,需要将WString转为String时,在debug模式下不报错,在release模式下报错。解决方案:修改release模式下设置 高级 -> 使用调试库 :是。虽然解决了这个问题,但是还是不清楚具体是什么原因导致。很奇怪的一个问题,没有明确的找到问题原因。原创 2023-07-28 16:28:23 · 305 阅读 · 0 评论 -
C++learn4
C++learn4 字符串 // C++learn4.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include <string> int main() { //C风格字符串 使用char数组 char greeting[] = "hello world"; std::cout << "" << greeting << std::endl; /原创 2020-11-05 17:47:37 · 115 阅读 · 0 评论 -
C++ practice1
红包程序 // Practice1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <ctime> #include <iostream> #include <math.h> int main() { int i, number; int best; //最佳的 float total; std::cout << "请输入红包金额: "; std::cin >> t原创 2020-11-05 16:41:24 · 164 阅读 · 0 评论 -
C++learn3
C++learn3 数据类型 数字 short s; //定义 int i; long l; float f; double d; s=10; //赋值 i=1000; l=1000000; f=230.67; d=302.22922; cout <<“short s :”<<s<<endl; cout <<“int i :”<<s<<endl; cout原创 2020-11-05 16:39:46 · 140 阅读 · 0 评论 -
C++learn2
C++ learn 2 变量分为局部变量,全局变量。 同c#相同,局部变量是在函数内部定义,仅在函数内部使用,函数外部访问不到。 全局变量为函数外部定义的变量。 在程序中,局部变量和全局变量的名称可以相同,但是在函数内,局部变量的值会覆盖全局变量的值。 当局部变量被定义时,系统不会对其初始化,必须自己初始化。 全局变量定义时,系统会自动初始化。 常量两种方式 #define LENGTH 10 宏定义,不加分号 const int i=10; 常规推荐使用 静态原创 2020-11-05 10:24:57 · 163 阅读 · 0 评论 -
C++ learn 1
在C++中,分别使用.h和.cpp来定义一个类 .h是头部文件,存放类的声明,函数原型(放在类的声明里) .cpp是源文件,存放函数体 也就是说,头文件存放声明(declaration),源文件存放定义(definition) 源文件调用这个头文件的时候,需要在源文件中#include 头文件 #include 头文件 <>和""的区别 <>:会先去系统目录中找头文件,如果没有再去当前目录下寻找,像是标准的头文件,如stdio.h,stdlib.h使用这个方法 “”:会先在当前原创 2020-11-03 16:35:08 · 152 阅读 · 0 评论