I was doing a program in c ++ (usually used an IDE to compile and everything), but this time I needed to do it without an IDE, so when I did the makefile to compile the program, it gave an error with something related to the class constructor
g ++ -c main.cpp g ++ -c grafos.cpp In file included from grafos.cpp: 1: 0: /usr/include/c++/5/bits/stl_construct.h: In instantiation of 'void std :: _Destroy (_Tp *) [with _Tp = Vertice] ': /usr/include/c++/5/bits/stl_construct.h:103:19: required from' static void std :: _ Destroy_aux < > :: __ destroy (_ForwardIterator, _ForwardIterator) [with _ForwardIterator = Vertice *; bool = false] '/usr/include/c++/5/bits/stl_construct.h:127:11: required from' void std :: _ Destroy (_ForwardIterator, _ForwardIterator) [with _ForwardIterator = Vertice *] '/ usr / include / c ++ / 5 / bits / stl_construct.h: 151: 15: required from 'void std :: _ Destroy (_ForwardIterator, _ForwardIterator, std :: allocator < _T2 > &) [with _ForwardIterator = Vertice *; _Tp = Vertice] '/usr/include/c++/5/bits/stl_vector.h:424:22: required from' std :: vector :: vector () [with _Tp = Vertice; _Alloc = std :: allocator] 'grafos.cpp: 3: 14: required from here grafos.h: 11: 2: error:' Vertice :: ~ Vertice () 'is private ~ Vertice (); ^ In file included from / usr / include / c ++ / 5 / vector: 62: 0, from grafos.h: 5, from grafos.cpp: 1: /usr/include/c++/5/bits/stl_construct.h:93 : 7: error: within this context {__pointer-> ~ _Tp (); } ^ makefile: 15: recipe for target 'grafo.o' failed make: *** [grafo.o] Error 1
grafos.h
#ifndef GRAFOS_H
#define GRAFOS_H
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Vertice{
private:
~Vertice();
int valor;
int peso;
vector<Vertice> listaAdjArest;
};
class Grafo{
private:
vector<Vertice> lista_v;
public:
Grafo();
~Grafo();
void InsereVertice(int valor);
void InsereAresta(int valor,int peso);
void ImprimirGrafo();
void ImprimirTopologicamente();
void ImprimirCaminhoCritico();
};
#endif
grafos.cpp
#include "grafos.h"
Grafo::Grafo()
{
}
Grafo::~Grafo(){
}
void Grafo::InsereVertice(int valor){
}
void Grafo::InsereAresta(int valor,int peso){
}
void Grafo::ImprimirGrafo(){
}
void Grafo::ImprimirTopologicamente(){
}
void Grafo::ImprimirCaminhoCritico(){
}
main.cpp
#include "grafos.h"
#include "dados.h"
int main(){
return 0;
}
makefile
all:Executar limpar
Executar: main.o grafos.o dados.o
g++ -Wall -o Projeto2 main.o grafos.o dados.o
main.o:main.cpp grafos.cpp grafos.h dados.cpp dados.h
g++ -c main.cpp
grafos.o:grafos.cpp grafos.h
g++ -c grafos.cpp
dados.o:dados.cpp dados.h
g++ -c dados.cpp
limpar:
rm -rf *.o
I'm not sure what's happening with the program, I tried to take some things out of the makefile, but I still have this problem, I also tried to find out if there was a similar problem, but I could not find anything at all, of some solution that can makefile compile the C ++ files together with the classes and the builders?, who can help me I thank
NOTE: the program git link, if any of you want to test to better analyze the problem link , you can see that the code is empty, only the classes and methods have been defined in the libraries and nothing else
NOTE: I have never had this problem, I have compiled it without any error or anything, but only in C ++ that is giving this problem, and IDE's compile this program without any problems.