Php C++;代码块
我在C中有简单的类声明++Php C++;代码块,php,c++,visual-studio,codeblocks,Php,C++,Visual Studio,Codeblocks,我在C中有简单的类声明++ class A { static void foo(void){ printf("Bar\n"); } }; 在Visual Studio 2013中,我可以通过A::foo()使用它,但在代码块中,我得到未定义的引用错误。如何在代码块中创建像PHP中那样的抽象方法(我不需要创建对象来调用此方法) 我的代码(在Visual Studio 2013中工作):您可以像以下示例中那样尝试: 样本h class Sample { sta
class A {
static void foo(void){
printf("Bar\n");
}
};
在Visual Studio 2013中,我可以通过A::foo()
使用它,但在代码块中,我得到未定义的引用
错误。如何在代码块中创建像PHP中那样的抽象方法(我不需要创建对象来调用此方法)
我的代码(在Visual Studio 2013中工作):您可以像以下示例中那样尝试: 样本h
class Sample
{
static int boo;
static void init()
{
boo = 1;
}
}
Sample.cpp
#include "Sample.h"
int Sample::boo;
用法:
#include "Sample.h"
cout << Sample::boo;
#包括“Sample.h”
cout问题在于代码块包含方法。在VisualI中,我包含了头文件,它工作正常,但代码块很愚蠢,不理解它。我们需要看到一个帮助you@NathanOliver你忽略了单词“Minimal”@NathanOliver Minimal-example在我的问题中..但你的Minimal-example是不可竞争或验证的。