标签: declaration

为什么我不能在Visual C++中声明以下函数"string timeToStr(string);"?

当我试图在.h文件中声明一个带有字符串参数的函数时,会发生错误.我没有忘记包含string.h =)当我使用char []时,一切都很好,但我希望参数是一个字符串.

c++ declaration function

0
推荐指数
1
解决办法
1675
查看次数

C语言.数组的声明,其大小由宏#define给出

我想知道为什么当我尝试使用#define我从编译器获取错误来声明数组时,使用文字而不是大小允许我这样做.

some_name.h:

#define size 10;

int* waitingBench[size];
Run Code Online (Sandbox Code Playgroud)

c arrays macros declaration c-preprocessor

0
推荐指数
2
解决办法
249
查看次数

当一个整数被声明为什么意味着什么?

我在网上做了一个俄罗斯方块教程,并注意到有一个这样的整数声明

int[][][] blah;
Run Code Online (Sandbox Code Playgroud)

为什么整数有3个括号?

java int declaration

0
推荐指数
1
解决办法
133
查看次数

如果功能被写在主要功能之上,则不需要声明功能.为什么?

在主函数之前编写函数体而不声明正确运行.但是在main函数需要明确声明函数之后编写函数体.为什么?

c pointers declaration function

0
推荐指数
1
解决办法
77
查看次数

int是什么意思

由于指定的标准int a属于简单declaration.其实

simple-declaration:
    decl-specifier-seq_opt init-declarator-list_opt ; //
    attribute-specifier-seq decl-specifier-seq_opt init-declarator-list ;
type-specifier:
    trailing-type-specifier //
    class-specifier
    enum-specifier
trailing-type-specifier:
    simple-type-specifier //
    elaborated-type-specifier
    typename-specifier
    cv-qualifier
simple-type-specifier:
    nested-name-specifieropt type-name
    nested-name-specifier template simple-template-id
    char
    char16_t
    char32_t
    wchar_t
    bool
    short
    int //
    long
    signed
    unsigned
    float
    double
    void
    auto
    decltype-specifier
Run Code Online (Sandbox Code Playgroud)

因此int a是一个简单的声明.但是,如果我们重新声明a与以下相同的范围:

int a;
int a;
Run Code Online (Sandbox Code Playgroud)

我们有

test.cpp:4:5: error: redefinition of ‘int a’
test.cpp:3:5: error: ‘int a’ previously declared here
Run Code Online (Sandbox Code Playgroud)

到底究竟int a是什么?

c++ declaration definition

0
推荐指数
2
解决办法
363
查看次数

c ++指针声明和赋值

int num1 = 8;   //okay
int *pointer;   //okay
*pointer = &num1;   //NOT okay, compiler says (Error:a value of type int* cannot be
                    //assigned to an entity of type "int")

int num2 = 8;   //okay
int *pointer = &num2;   //okay
Run Code Online (Sandbox Code Playgroud)

我很困惑为什么第一部分给出错误而第二部分没有,它们看起来和我一样

c++ pointers declaration

0
推荐指数
1
解决办法
7519
查看次数

C编程术语

拿这个宣言:

int i = 80;
Run Code Online (Sandbox Code Playgroud)

这是我对用于描述每个部分的术语的理解(如果我错了,请纠正我):

  • int 是变量类型
  • i 是声明者
  • = 是赋值操作数

什么术语用来形容80

另一个例子:

char *c = "a";
// char - variable type
// c    - declarator
// =    - assignment operand
// "a"  - ?
Run Code Online (Sandbox Code Playgroud)

c variables declaration

0
推荐指数
1
解决办法
51
查看次数

Haskell,typesig Map.Map,LYAH

我不太了解Map.Map部分.据我所知,当我导入限定为Map时,我需要将寻址前缀为"Map".但是通常后面跟着一个函数(例如"查找"),这里使用了两种类型.

import qualified Data.Map as Map 
phonebook :: Map.Map String String
Run Code Online (Sandbox Code Playgroud)

我得到的电话簿需要一个字符串和一个字符串,但严格来说Map.Map表示它是一个关联列表,还是有更多呢?为什么省略箭头?

haskell types declaration

0
推荐指数
1
解决办法
193
查看次数

变量/函数可以声明多次,但只能定义一次

变量/函数可以声明多次,但只能定义一次。这实际上是什么意思?

我试图了解有关在线编译器的声明,但我期望显示错误,但事实并非如此。

#include <stdio.h>
int x=10;

int main() {
    x=20;
    x=30;

    printf("%d",x);
}
Run Code Online (Sandbox Code Playgroud)

预期的输出:因为我已经定义了变量x并分配了三个不同的值10、20、30,所以我希望显示错误。这个概念说您可以声明变量多次,但只能定义一次,因为不能将两个不同的位置赋给同一变量实际输出:30

c variables declaration definition

0
推荐指数
1
解决办法
75
查看次数

为什么fputs()需要常量作为第一个参数而不是fputc()?

int fputc(int c, FILE *stream);

int fputs(const char *s, FILE *stream);
Run Code Online (Sandbox Code Playgroud)

为什么const int c在fputc()的声明中不需要?

c parameters declaration function definition

0
推荐指数
1
解决办法
94
查看次数