小编and*_*927的帖子

C++:指针在传递后包含不同的地址

所以我有一些像这样的代码:

#include <iostream>

using namespace std;

class Base1 {};
class Base2 {};

class A
{
public:
    A() {}
    void foo(Base2* ptr) { cout << "This is A. B is at the address " << ptr << endl; }
};

A *global_a;

class B : public Base1, public Base2
{
public:
    B() {}
    void bar()
    {
        cout << "This is B. I am at the address " << this << endl;
        global_a->foo(this);
    }
};

int main()
{
    global_a = new A(); …
Run Code Online (Sandbox Code Playgroud)

c++ pointers multiple-inheritance memory-address visual-studio-2013

3
推荐指数
2
解决办法
140
查看次数

如何(廉价地)计算n个可能元素的所有可能的长度-r组合

什么是计算n个可能元素的所有可能长度-r组合的最快方法,而不采用强力技术或任何需要STL的东西?

在我的数据结构类中为我的最终项目开发Apriori算法时,我开发了一个使用位移和递归的有趣解决方案,我将在下面的回答中分享对任何感兴趣的人.但是,这是实现这一目标的最快方法(不使用任何通用库)吗?

我出于好奇而不是其他任何问题,因为我目前的算法对我的目的来说效果很好.

c c++ java bit-manipulation combinatorics

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