C++中Argument和Parameter这两个词的含义

2023-11-02

用中文讲就是在C++中,Argument指实参,Parameter指形参。


[ZZ]http://www.devx.com/tips/Tip/13049

Understanding the Difference Between an Argument and a Parameter

The words argument and parameter are often used interchangeably in the literature, although the C++ Standard makes a clear distinction between the two. An argument is one of the following: an expression in the comma-separated list in a function call; a sequence of one or more preprocessor tokens in the comma-separated list in a macro call; the operand of a throw-statement or an expression, type, or template-name in the comma-separated list in the angle brackets of a template instantiation. A parameter is one of the following: an object or reference that is declared in a function declaration or definition (or in the catch clause of an exception handler); an identifier between the parentheses immediately following the macro name in a macro definition; or a template-parameter. This example demonstrates the difference between a parameter and an argument:

void func(int n, char * pc); //n and pc are parameters
template <class T> class A {}; //T is a a parameter

int main()
{
  char c;
  char *p = &c;
  func(5, p); //5 and p are arguments
  A<long> a; //'long' is an argument
  A<char> another_a; //'char' is an argument
  return 0;
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

C++中Argument和Parameter这两个词的含义 的相关文章

  • 哪些 iomanip 操纵器具有“粘性”?

    我最近在创建一个stringstream由于我错误地假设std setw 会影响每次插入的字符串流 直到我明确更改它 然而 插入后它总是被取消设置 With timestruct with value of Oct 7 9 04 AM st
  • 除了第一列之外,Gridview 行可点击?

    我使用以下代码使 gridview 的整行可单击 protected void gridMSDS RowDataBound object sender GridViewRowEventArgs e if e Row RowType Data
  • C# 动态 Linq 变量Where 子句

    我正在按照 Scott Gu 的文章创建动态 LINQhttp weblogs asp net scottgu archive 2008 01 07 dynamic linq part 1 using the linq dynamic qu
  • 堆栈独立的C/C++蓝牙API?

    我想知道是否有适用于 Windows XP Vista 7 x86 和 x64 的堆栈独立 C C 蓝牙 api 我的目标是创建连接并通过蓝牙发送 接收一些时间关键的数据 我的研究给了我以下选择以及这项任务的缺点 用于蓝牙的 Windows
  • 如何在 asp .net mvc 2 中对不直接属于我的模型的对象使用 DisplayFor()?

    我确信我在这里遗漏了一些非常简单的东西 我创建了一个自定义日期时间显示模板 使用以下方法时效果很好 但是 我遇到了这样的情况 在部分控件内 我在 for 循环中迭代模型中的对象 我想要一个 DateTime 属性来使用显示模板 但我不知道如
  • string.empty 和 string[0] == '\0' 之间的区别

    假设我们有一个字符串 std string str some value is assigned 有什么区别str empty and str 0 0 C 11 及更高版本 string variable 0 如果字符串为空 则需要返回空字
  • DLL 需要访问其应用程序的符号

    在 C 中 DLL 是否可以访问加载它的应用程序的某些符号 我有一个加载插件 dll 的应用程序 这些插件需要访问该应用程序的某些API 是否可以在不创建共享此 API 的新 DLL 的情况下实现此目的 函数指针结构适合这种情况吗 示例 主
  • 如何使用 ASP.NET MVC 4.0 DonutOutputCache VaryByCustom 使缓存失效

    我正在为我的 ASP NET 应用程序使用 DevTrends MvcDonutCaching 包 它工作得很好 我目前遇到的一个问题是使我为子操作设置的 VaryByCustom 缓存无效 这是我用于 VaryByCustom 设置的一些
  • 如何在单独的类库中管理客户端上下文对象?

    我正在尝试创建一个库 类库 对于共享点 它将拥有所有共享点 dll 来与共享点服务器交互上传文件 文档并创建文档库和文档集 现在这个库可以被使用客户端 例如 Web 应用程序 asp net webform 或 mvc 或控制台应用程序或
  • PostgreSQL 自定义异常条件

    当我提出异常时是否可以创建自定义条件 考虑以下示例 BEGIN y x 0 EXCEPTION WHEN division by zero THEN RAISE NOTICE caught division by zero RETURN x
  • 在 C# 中使用 as 关键字与泛型类型发生冲突的编译时行为

    当尝试对无法转换为的非泛型类型使用 C as 关键字时 编译器会给出无法转换类型的错误 但是 当对泛型类型使用 as 关键字时 编译器不会给出错误 public class Foo public class Bar
  • 从 Linq 的列表中选择多个字段

    在 ASP NET C 中 我有一个结构 public struct Data public int item1 public int item2 public int category id public string category
  • CS0246 找不到类型或命名空间名称“ErrorViewModel”(您是否缺少 using 指令或程序集引用?)

    我收到 CS0246 错误代码 我正在做一个 MVC net core 项目 我正在将 Razor 合并到我的 C 代码中 我在进行构建时收到此错误 我在最后一行收到错误 有人能帮我解决这个问题吗 global Microsoft AspN
  • 如何定义 Swagger UI 参数的默认值?

    我已将 Swagger Swashbuckle 集成到 NET Core 2 2 API 项目中 一切都很好 我的要求纯粹是为了方便 考虑以下 API 方法 public Model SomeEstimate SomeRequest req
  • System.Drawing.Icon 构造函数抛出“操作成功完成”异常

    在 Windows XP 计算机上 以下代码抛出 System ComponentModel Win32Exception 并显示消息 操作成功完成 System Drawing Icon icon new System Drawing I
  • std::regex 转义正则表达式中使用的特殊字符

    我是字符串来创建一个std regex FILE 作为单元测试的一部分 检查一些打印文件名的异常输出 在 Windows 上失败并显示 regex error error escape 表达式包含无效的转义字符或尾随转义 因为 FILE 宏
  • g++4.9 不支持 std::align

    在学习对齐问题等时 我意识到我的 g 4 9 macports OS X 实现不支持std align 如果我尝试编译 使用 std c 11 此示例代码来自http www cplusplus com reference memory a
  • 为 C++ 类播种 rand()

    我正在开发一个 C 类 它使用rand 在构造函数中 我真的希望这个班级在几乎所有方面都能照顾好自己 但我不知道在哪里播种rand 如果我播种rand 在构造函数中 每次构造我的对象类型的新实例时都会对其进行播种 因此 如果我按顺序创建 3
  • 可选参数代码在 .NET 3.5 中编译。为什么?

    这段代码在 VS 2010 的框架 3 5 项目中编译正常 我三次检查过 public LoggingClient string uri net msmq localhost logging 为什么 我在 C 4 规范中没有看到任何内容 文
  • Android NDK - 仅用 C/C++ 编写

    有没有一种可能的方法可以使用 C C 编写整个 NDK 应用程序 而无需像 hello jni 示例项目 HelloJni java 中那样的 Java 入门 类 以某种方式创建一个 HelloJni c 来执行相同的操作 从 Androi

随机推荐