相关疑难解决方法(0)

使用G ++编译多个.cpp和.h文件

我刚刚继承了一些C++代码,这些代码写得不好用一个cpp文件,其中包含main和一堆其他函数.还有一些.h文件包含类及其函数定义.

到目前为止,该程序是使用该命令编译的g++ main.cpp.现在我已经将类.h.cpp文件分开了,我需要使用makefile还是我仍然可以使用g++ main.cpp命令?

c++ makefile compilation header

148
推荐指数
7
解决办法
28万
查看次数

未定义对代码块中功能的引用

我在头文件和源文件中有此代码。这是代码的小片段。这是来自.cpp文件。

int sample(Cdf* cdf)  
{
    //double RandomUniform();
    double r = RandomUniform(); //code that is causing the error
    for (int j = 0; j < cdf->n; j++)
    if (r < cdf->vals[j])
    return cdf->ids[j];
    // return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是从.c文件:

double RandomUniform(void)
{
    double uni;

    /* Make sure the initialisation routine has been called */
    if (!test) 
    RandomInitialise(1802,9373);

    uni = u[i97-1] - u[j97-1];
    if (uni <= 0.0)
    uni++;
    u[i97-1] = uni;
    i97--;

    // ...
}
Run Code Online (Sandbox Code Playgroud)

这是从我的头文件

void   RandomInitialise(int,int);
double …
Run Code Online (Sandbox Code Playgroud)

c c++ codeblocks

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

标签 统计

c++ ×2

c ×1

codeblocks ×1

compilation ×1

header ×1

makefile ×1