C++ "not declared in this scope" error, with include files -
in code include following (this excerpt, make reader understand problem):
#include <iostream> #include <gsl/gsl_sf_gamma.h> #include <gsl/gsl_integration.h> #include "metry.h" #include "growth.h" #include <vector> using namespace std; struct integral_params{ double = 1.; double b = 1.; }; double f(double chizero, void* pp) { integral_params *ip=static_cast<integral_params*>(pp); params cp; bool cls = true; cosmo=new metry(cp); structure=new growth(cp,cls); }
at beginning of metry.h
have
#ifndef metry_h #define metry_h #include <gsl/gsl_spline.h> #include "cosmology.h" class metry : public virtual cosmology
which connected therefore cosmology.h
, @ beginning of have
#ifndef cosmology_h #define cosmology_h struct params { //bla bla }
and
class cosmology { //bla bla }
instead in growth.h
have
#ifndef growth_h #define growth_h #include <gsl/gsl_spline.h> #include "cosmology.h" #include "spectrum.h"
and in spectrum.h
#ifndef spectrum_h #define spectrum_h #include "cosmology.h"
when compile following problem:
in function ‘double f(double, void*)’: : error: ‘cosmo’ not declared in scope cosmo=new metry(cp); ^~~~~ : error: ‘structure’ not declared in scope structure=new growth(cp,cls); ^~~~~~~~~
can me understand why logical order wrong in definitions , should fix this?
wiki
Comments
Post a Comment