Message from C, C++ discussions

January 2020

— Dima and Dima ?

— 

Hey guys, it seems that I often fall into a bad pattern that results in circular dependency issues. This is related to templated methods. I'll provide below a sample of the stated pattern. If someone has experience in how to avoid this, I'll be grateful :)

— #pragma once

— 

/* a.hpp */
#include "b.hpp"
class A
{
public:
A() : b(*this) {}

int whatever_property;

private:
B _b
};

/* b.hpp */

class A;
class B
{
public:
B() = delete;
B(A &a) : _a(a) {}

template <typename T>
void foo(T t)
{
//Here I need the complete type definition
_a.whatever_property += t;
}

private:
A &_a;
};

Message permanent page

— With my configuration, it won't prevent the error

— User invest_with has 1/2 warnings; be careful!
The latest warn was because:
crypto that 1000% works

— Oh sorry

— No worries!

— Can anyone reply please

— Any standard and complete resources or documentation for C and C++

— There's probably a better design, but I faced a similar problem a while ago and ended up changing the design

Message permanent page

— Generally it' s not a problem since we can move the complete type inclusion in a cpp file. But when I need to use both the templated parameter and the complete A type, I end up with this. It's very limiting

Message permanent page