按照书我读,rand()需要#include <cstdlib>在C++
但是,我能够编译使用下面的代码rand()没有#include <cstdlib> ,也没有using namespace std;在Visual Studio 2015年
为什么不需要这两个编译?我应该包括cstdlib吗?
C++代码:
#include <iostream>
int main()
{
std::cout << rand() << std::endl;
}
Run Code Online (Sandbox Code Playgroud) 我正在制作一个 Unity C# 脚本,供其他人用作角色对话工具来写出多个游戏角色之间的对话。
我有一个DialogueElement类,然后我创建了一个DialogueElement对象列表。每个对象代表一行对话。
[System.Serializable] //needed to make ScriptableObject out of this class
public class DialogueElement
{
public enum Characters {CharacterA, CharacterB};
public Characters Character; //Which characters is saying the line of dialog
public string DialogueText; //What the character is saying
}
Run Code Online (Sandbox Code Playgroud)
public class Dialogue : ScriptableObject
{
public string[] CharactersList; //defined by the user in the Unity inspector
public List<DialogueElement> DialogueItems; //each element represents a line of dialogue
}
Run Code Online (Sandbox Code Playgroud)
我希望用户能够仅通过与 Unity 检查器交互来使用对话框工具(因此无需编辑代码)。这种设置的问题是对话工具的用户无法为Characters枚举中的字符指定他们自己的自定义名称(例如 …