标签: declaration

转发声明命名空间中的类

我很惊讶地发现我无法使用范围解析运算符从另一个范围转发声明一个类,即

class someScope::someClass;
Run Code Online (Sandbox Code Playgroud)

相反,必须使用完整声明如下:

namespace
{
    class someClass;
}
Run Code Online (Sandbox Code Playgroud)

有人可以解释为什么会这样吗?

更新:澄清一下,我在问为什么会这样.

c++ scope namespaces declaration

14
推荐指数
2
解决办法
2524
查看次数

在Linux平台上声明c中的bool变量

如何在Linux平台上运行的C中声明bool数据类型的变量.我尝试了以下但它给出了一个错误:

#include<stdio.h>
#include<string.h>

bool factors[1000]
void main()
{
}
Run Code Online (Sandbox Code Playgroud)

c variables boolean declaration

14
推荐指数
2
解决办法
8万
查看次数

popen隐式声明,即使添加了#include <stdio.h>

这是我的代码的一小部分.

   #include <stdio.h>
   #include <unistd.h>
   #include <stdlib.h>
   #include <time.h>
   #include <sys/stat.h>
   #include <sys/wait.h>
   #include <sys/types.h>
   #include <string.h>
   #include <sys/types.h>
   #include <sys/socket.h>
   #include <netinet/in.h>
   #include <arpa/inet.h>
    ...

   FILE * pipe;
    ...

   pipe = popen ("ls /tmp -1", "r");
    ...
   pclose(pipe);
Run Code Online (Sandbox Code Playgroud)
blarg.c:106: warning: implicit declaration of function ‘popen’

blarg.c:106: warning: assignment makes pointer from integer without a cast

blarg.c:112: warning: implicit declaration of function ‘pclose’

blarg.c:118: warning: assignment makes pointer from integer without a cast
Run Code Online (Sandbox Code Playgroud)

我真的不确定.我查了一下popen,它需要的是stdio.h.缺少什么,或者是我的其余代码中的问题(我真的不想显示更多的代码,因为它是一个赋值).

c declaration pipe stdio implicit

14
推荐指数
2
解决办法
8615
查看次数

为什么我不能创建一个自动变量数组?

在C++ 0x(哦!读取C++ 11)中,我们有自动类型推断.令我好奇的一件事是我无法创建一系列自动变量.例如:

auto A[] = {1, 2, 3, 4}; // Error!
Run Code Online (Sandbox Code Playgroud)

有什么想法可能被禁止了吗?

c++ declaration c++11

14
推荐指数
2
解决办法
3088
查看次数

在C#中使用"小于"和"大于"符号之间的类名是什么意思?

我不明白以下的类声明:

public abstract class Class1 <TDomainServiceContract, TDomainService>
{
   ...
}
Run Code Online (Sandbox Code Playgroud)

我知道TDomainServiceContractTDomainService是的,但为什么他们之间使用<>符号?

c# generics class declaration

14
推荐指数
2
解决办法
6541
查看次数

在声明中缺少部分修饰符..这种类型的另一部分声明存在".我是初学者,只是跟着这本书

我是初学者,我正在按照一本书做练习.下面是我的代码,我得到了这个

"Missing partial modifier on declaration of type 'Windowsform.Form1'; another partial declaration of this type exists".

我该怎么办?我的代码如下:

using System;
using System.Windows.Forms;

namespace Windowsform
{
    public class Form1 : Form
    {
       private TextBox txtEnter;
       private Label lblDisplay;
       private Button btnOk;

       public Form1()

       {
           this.txtEnter = new TextBox();
           this.lblDisplay = new Label();
           this.btnOk = new Button();
           this.Text = "My Hellowin app!";


           //txtEnter
           this.txtEnter.Location = new System.Drawing.Point(16, 32);
           this.txtEnter.Size = new System.Drawing.Size(264, 20);

           //lblDisplay
           this.lblDisplay.Location = new System.Drawing.Point(16, 72);
           this.lblDisplay.Size = …
Run Code Online (Sandbox Code Playgroud)

c# declaration partial winforms form-control

14
推荐指数
2
解决办法
6万
查看次数

在通过参考传递参数时可以放置&符号"&"?

在我看到的示例中,参数通过以下方式通过引用传递:

void AddOne(int &y)
Run Code Online (Sandbox Code Playgroud)

在我的代码中,我看到以下语法:

void AddOne(int& y)
Run Code Online (Sandbox Code Playgroud)

我想知道它是否相同或第二种情况与第一种情况有所不同.

c++ pointers reference declaration

14
推荐指数
1
解决办法
4962
查看次数

关于声明的螺旋规则 - 何时出错?

我最近学习用于去复制复杂声明的螺旋规则,它必须用一系列typedef编写.但是,以下评论警告我:

经常引用的简化,仅适用于少数简单案例.

我找不到void (*signal(int, void (*fp)(int)))(int);"简单的案例".顺便说一句,哪个更令人担忧.

所以,我的问题是,在哪种情况下,我应用规则是正确的,哪些是错误的?

c declaration

14
推荐指数
4
解决办法
4038
查看次数

何时使用UIKIT_EXTERN vs extern

我猜我只会使用UIKIT_EXTERN,如果我的项目中有可能使用该变量的C++代码.

如果是这种情况,用UIKIT_EXTERN声明所有外部可用的常量是否安全?

为什么我不再看到这个?

visibility declaration objective-c extern

14
推荐指数
1
解决办法
5314
查看次数

我应该在函数定义中还是在声明和定义中放置参数存储类说明符?

我正在努力将一些旧的K&R代码移植到ANSI C,所以我正在编写缺少的函数原型声明.很多函数定义都有寄存器存储类的参数,但是我不确定函数原型中是否可以省略寄存器存储类说明符?

有和没有寄存器存储类特定声明,代码编译正确(我尝试了GCC,VC++和Watcom C).我在ISO/ANSI C89标准中找不到任何关于正确方法的信息 - 如果我只是将register关键字放在函数定义中就可以了吗?

int add(register int x, register int y); 

int add(register int x, register int y)
{
  return x+y;
}
Run Code Online (Sandbox Code Playgroud)

这也正确构建:

int add(int x, int y);

int add(register int x, register int y)
{
   return x+y;
}
Run Code Online (Sandbox Code Playgroud)

我想确保根据标准真正考虑寄存器存储说明符(我的目标是使用非常旧的编译器进行编译,其中此存储类说明符很重要).两者都好,这只是一个编码风格的问题,或不是?

c declaration definition c89

14
推荐指数
3
解决办法
590
查看次数