M
M
Maxim2018-07-22 21:54:59
C++ / C#
Maxim, 2018-07-22 21:54:59

How to include header without error?

There are 4 files

layer.hpp
#pragma once

class Neuron;

class Layer
{
    private:
        Neuron *neurons;
        int size;
    public:
        Layer();
        ~Layer();
};
neuron.hpp
#pragma once

class Layer;

class Neuron
{
    private:
        float *weight;
    public:
        Neuron();
        ~Neuron();
        float execute(const Layer &layer);
};

layer.cpp
#include "layer.hpp"

Layer::Layer(){}
Layer::~Layer(){}

neuron.cpp
#include "neuron.hpp"

Neuron::Neuron() {}
Neuron::~Neuron(){}
float Neuron::execute(const Layer &layer)
{
    return 0.0;
}


and main.cpp
#include "neuron.hpp"
#include "layer.hpp"

int main(int argc, char const *argv[])
{
    Neuron n;
    Layer l;

    return 0;
}

Why does the g++ compiler write that constructors with destructors and a method are not defined?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2018-07-22
@Got_Oxidus

Why does the g++ compiler write that constructors with destructors and a method are not defined?

g++ main.cpp neuron.cpp layer.cpp -o test

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question