explicit type is missing

Jul 10, 2021 at 11:12am
I have a header file and a cpp like this,
in the mesh::mesh_build I get the error explicit type is missing,how can I solve it?

Last edited on Jul 12, 2021 at 10:42am
Jul 10, 2021 at 1:42pm
Mesh_build() is a function. It needs a return type or if it doesn't return anything then the return type should be void

 
void Mesh_build(size_t Nnodes, size_t Nelms, VecVecDbl_t Coordinates, VecVecIdx_t Connectivities);


BTW, lines 20,30: fileName should be const reference rather than passing by value.
 
Mesh(const std::string & FileName);

Last edited on Jul 10, 2021 at 1:45pm
Jul 10, 2021 at 2:09pm
Thanks for your answer, I guessed the same about both items you explained.
Thanks
Jul 10, 2021 at 10:38pm
@AbstractionAnon imagine I want to open one text file named mesh and obtain the size of connectivities, how it gonna be?
For example I can say something like this?
Mesh Global_Mesh(const std::string filename)
Global_Mesh.connectivities_.size()? I have one error in compiling here.
Last edited on Jul 10, 2021 at 10:39pm
Jul 10, 2021 at 11:26pm
What's the error?

Line 14: Connectivities_ is capitalized.
In your question: Global_Mesh.connectivities_.size()? is not capitalized.

Jul 11, 2021 at 12:09am
In code both of them are capitalized, it says expression must have a class type.
Jul 11, 2021 at 6:46am
Please show the declaration for VecVecDbl_t.
Jul 11, 2021 at 10:28am
1
2
typedef std::vector<double>             VecDbl_t;
typedef std::vector<VecDbl_t>           VecVecDbl_t;
Last edited on Jul 11, 2021 at 10:29am
Jul 11, 2021 at 10:50am
1
2
3
4
// declare function that takes string parameter and returns a Mesh:
Mesh Global_Mesh(const std::string filename);

cout << Global_Mesh.connectivities_.size(); // error, Global_Mesh is name of a function 
Jul 11, 2021 at 10:59am
you mean making Mesh(const std::string FileName); as a void function?
Jul 11, 2021 at 11:28am
No. If you have line:
Mesh Global_Mesh( const std::string filename );
Then you do have a function declaration.

If you want to declare a variable 'Global_Mesh' and initialize it with value of existing variable 'filename', then you should have:
Mesh Global_Mesh( filename );
Jul 11, 2021 at 12:14pm
I have done this in my code but still I have the same error.
Jul 11, 2021 at 1:15pm
Is "expression must have a class type" the whole, exact error message? Compiler usually tells more than that.

We don't see enough of your code to even start to guess.
Jul 12, 2021 at 1:09pm
@resabzr Why have you deleted the code from your earlier posts? Please don't do that - it makes the thread incomprehensible for those looking to learn from it.
Jul 12, 2021 at 1:14pm
Sure.
Topic archived. No new replies allowed.