标签: declaration

在java中,为什么我可以声明一个名为"a"而不是"1"的变量?

我宣布一切都很好

String a;
Run Code Online (Sandbox Code Playgroud)

但它表示令牌"1"上的语法错误,当我这样做时,VariableDeclaratorId无效

String 1;
Run Code Online (Sandbox Code Playgroud)

这是为什么?

java variables declaration

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

外部变量声明和定义

a)外部变量的定义与局部变量的定义相同,即int i=2;(仅在所有函数之外).但为什么extern int i=2;这个定义过于有效呢?是否extern仅用于其他文件中的变量声明?

b)文件1

  #include<stdio.h>
  int i=3;
  int main()
  {
      printf("%d",i);
      fn();
  }
Run Code Online (Sandbox Code Playgroud)

文件2

  int i;  //  although the declaration should be: extern int i; So, why is this working?
  void fn()
  {
      printf("%d",i);
  }
Run Code Online (Sandbox Code Playgroud)

输出:两种情况均为3

c variables external declaration definition

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

吃豆子游戏的东西没有申报?

我在编译时遇到这两个错误,但我不明白我做的不对.

main.cpp | 107 |错误:在此范围中未声明'sqrt'

main.cpp | 107 |错误:在此范围中未声明'pow'

#include <iostream>
#include <Windows.h>
using namespace std;

struct Player
{
    int x, y;
    Player()
    {
        x = -1;
        y = -1;
    }
};

struct Ghost
{
    int x, y, direction;
    Ghost()
    {
        x = -1;
        y = -1;
        direction = 1;
    }
};

const char SYMBOL_EMPTY = ' ';
const char SYMBOL_PLAYER = '@';
const char SYMBOL_GHOST = 'G';
const char SYMBOL_WALL = '#';
const int MapDx = 10;
const int …
Run Code Online (Sandbox Code Playgroud)

c++ scope declaration

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

动态变量声明

假设我们已将数据加载到单元格数组中:

DATA={'foo',[1,5];'bar',[2,6]}
Run Code Online (Sandbox Code Playgroud)

有没有办法如何用第DATA2列的内容声明第1列命名的变量?

variables matlab declaration

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

未初始化的变量/指针变成定义或声明?

假设我有以下程序:

int main(void)
{
int i; //Line 1
i=5;  //Line 2

int *j; //line 3
j=&i; //line 4
}
Run Code Online (Sandbox Code Playgroud)

如果我尝试在Visual Studio中的第1行之后打印i,它会给出一个编译时错误,说明我使用的单元化变量.这是否意味着没有为i分配存储,而第1行只是一个声明?我理解第2行是一个定义.

还有,第3行和第4行呢?他们是宣言还是定义?

c declaration definition

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

如何在c#中声明int表的列表?

我的声明如下:

IList<int[]> populacja = new List<int[]>();
Run Code Online (Sandbox Code Playgroud)

但我想声明一个int表的常量大小.所以我想要这样的东西

IList<int[2]> populacja = new List<int[2]>();
Run Code Online (Sandbox Code Playgroud)

怎么做?制作int表列表的好方法是什么?

c# declaration list

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

在聚合物中宣布一种功能

我试图在另一个中使用一个函数,但即使我事先声明它,聚合物说它不是.我不明白.任何线索?

Polymer({
is: 'x-foo',

//some other code here, including the properties....

computeRange: function (offset, limit, nodeRangeStart, nodeRangeEnd) {
  nodeRangeStart.innerText = offset;
  nodeRangeEnd.innerText = offset + limit;
},
prevPage: function () {
  this.offset = this.offset - this.limit;
  computeRange(this.offset, this.limit, this.$.usersListRangeStart, this.$.usersListRangeEnd);
  this.$.nextPage.removeAttribute('disabled');
  if (this.offset <= 0) {
    this.$.prevPage.setAttribute('disabled', true);
    this.$.prevPage.style.color = '#DDDDDD';
  };
}

});
Run Code Online (Sandbox Code Playgroud)

和控制台:

未捕获的ReferenceError:未定义computeRange

declaration function polymer

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

Java - 如何"随时随地"选择泛型类

我实现了一个泛型类,我想根据用户的选择创建一个具有特定类型的变量.我希望无论用户选择什么,变量的名称都是相同的.

到目前为止我得到了什么:

public class MyGeneric <T>
{
...
}
Run Code Online (Sandbox Code Playgroud)

主要:

if(choice==1)
     MyGeneric<Integer> item = new MyGeneric<Integer>();
else
     MyGeneric<String> item = new MyGeneric<String>();
Run Code Online (Sandbox Code Playgroud)

我知道内部的声明if是被禁止的.

我能做什么?


之所以这样做,就是那个.

第一个选项更具可读性和"通用"..

java generics if-statement class declaration

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

动态类型声明

我需要写一个FM,我会收到一个元素的数据类型作为字符串参数,我想声明它:

DATA: lt_test TYPE TABLE OF (iv_data_type).
Run Code Online (Sandbox Code Playgroud)

iv_data类型应该是接收类型.

sap abap declaration dynamic function-module

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

C++类原型不能正常工作?

我正在尝试创建一个类原型,但是我不断收到错误:'aClass'使用未定义的类'myClass'

我很确定我正在制作原型.使用原型函数可以工作,但是类原型没有.

extern class myClass;               // prototypes
extern void myFunction();

int main()                          // main
{
    myClass aClass;
    myFunction();
    return 0;
}

class myClass {                     // this doesn't work
public:
    void doSomething() {
        return;
    }

    myClass() {};
};
void myFunction() {                 // this works
    return;
}
Run Code Online (Sandbox Code Playgroud)

c++ class declaration definition forward-declaration

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