) 해결하기가 매우 쉽지만 C++에서 올바른 형식주의를 찾을 수없는 문제가 있습니다. 주어진 헤더 파일의 다른 클래스의 객체를 선언하고 싶습니다. 불행히도 오류가 발생합니다 :다른 헤더 파일에있는 객체 선언
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
calc/solver_nonl/new_raphs.cpp: In constructor
‘new_raphs::new_raphs(Eigen::MatrixXd, Eigen::MatrixXd, Eigen::MatrixXd, Eigen::MatrixXd, Eigen::MatrixXd)’:
calc/solver_nonl/new_raphs.cpp:7:44: error: no matching function for call to ‘stiff_nonl::stiff_nonl()’
:set_force(node_matrix,dof_matrix_input)
^
calc/solver_nonl/new_raphs.cpp:7:44: note: candidates are:
In file included from calc/solver_nonl/new_raphs.h:8:0,
from calc/solver_nonl/new_raphs.cpp:1:
calc/solver_nonl/../fem_nonl/stiff_nonl.h:20:5: note: stiff_nonl::stiff_nonl(Eigen::MatrixXd, Eigen::MatrixXd, Eigen::MatrixXd, Eigen::MatrixXd)
stiff_nonl(MatrixXd node_matrix, MatrixXd dof_matrix_input, MatrixXd element_matrix, MatrixXd element_info_matrix);
^
calc/solver_nonl/../fem_nonl/stiff_nonl.h:20:5: note: candidate expects 4 arguments, 0 provided
calc/solver_nonl/../fem_nonl/stiff_nonl.h:17:7: note:
stiff_nonl::stiff_nonl(const stiff_nonl&)
class stiff_nonl : public set_force
^
calc/solver_nonl/../fem_nonl/stiff_nonl.h:17:7: note: candidate expects 1 argument, 0 provided
calc/solver_nonl/new_raphs.cpp: In member function ‘Eigen::MatrixXd& new_raphs::get_epsilon_results(int, int)’:
calc/solver_nonl/new_raphs.cpp:92:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
make: *** [all] Fehler 1
자주 다른 클래스의 객체를 선언했지만 여기에 무엇이 잘못 되었습니까? 다음과 같이
헤더 파일은 같습니다
#ifndef NEW_RAPHS_H
#define NEW_RAPHS_H
# include "../../pre/boundary_force/set_force.h"
# include <iostream>
#include "../fem_lin/stiff.h"
#include "../fem_nonl/stiff_nonl.h"
using namespace std;
class new_raphs : set_force
{
public:
new_raphs(MatrixXd node_matrix, MatrixXd dof_matrix_input, MatrixXd element_matrix, MatrixXd element_info_matrix, MatrixXd force_matrix_input);
MatrixXd elements;
MatrixXd elements_info;
MatrixXd force_matrix;
void calc();
VectorXd U;
MatrixXd res;
MatrixXd result_matrix;
MatrixXd &get_result();
stiff_nonl stiffness_nonl; // here is the bug!
MatrixXd &get_epsilon_results(int noe, int num_gauss_point);
};
#endif // NEW_RAPHS_H
그는 obviousely 선언처럼 나던 stiff_nonl stiffness_nonl; ??? stiff_nonl 클래스가 다른 클래스에서 상속 받도록 할 일이 있습니까? 선언문에서 이것을 고려해야합니까?
C++ 검사기 중 하나가 여기에서 나를 도울 수 있으시겠습니까?
미리 감사드립니다.
건배 Franz
는'stiff_nonl'(아무 인수 포함) 기본 생성자를 부여하거나 올바른 인수가 아마 당신의 문제를 해결할 것입니다 ... 나에게 조금 이상하다. 주의 : 타입을 명명 할 때 각 단어의 첫 문자를 캡쳐 화하는 것이 일반적입니다.'stiff_nonl'은 아마도'Stiff_Nonl'이어야합니다. – George
아마도 stiffness_nonl을 new_raphs의 생성자 초기화 목록에 추가하면 도움이 될 것입니다. (George가 보여준 문제와 약간 다른 해결책) – stefaanv