← Back to team overview

yade-dev team mailing list archive

need help on ClumpTemplate

 

Hi all,

As mentioned some days ago, I need some help on c++.
I want to create a new class ClumpTemplate. When it is constructed it just should store some informations:
- an id for the template
- number of clump members (numCM)
- relative radii list (length == numCM)
- relative postions list (length == numCM)

For initiation the length (numCM) is unknown. This is what I have done until know:

//######code for ClumpTemplate.hpp:

#pragma once

class ClumpTemplate {
	public:
		typedef const int id_ct;
		typedef const shared_ptr<ClumpTemplate> ct;
		ClumpTemplate ct;

		int numCM;		//number of clump members
		Real[] rad;		//relative radii list
		Vector3r[] pos;		//rel. position vector list

		int ClumpTemplate();	//returns id
};


//######code for ClumpTemplate.cpp:

#include <yade/core/ClumpTemplate.hpp>
class ClumpTemplate;

// set id to -1, if not constructed yet
const ClumpTemplate::id_ct ClumpTemplate::ID_NONE=ClumpTemplate::id_ct(-1);

int ClumpTemplate::ClumpTemplate(){
	int id = this.id_ct + 1;
	return id;
}

//####compiler says:

[ 14%] Built target support
[ 15%] Building CXX object CMakeFiles/core.dir/core/ClumpTemplate.cpp.o
In file included from /home/me/YADE/working_on_trunk/core/ClumpTemplate.cpp:6:
/home/me/YADE/YADE201302/yade/core/ClumpTemplate.hpp:11: error: ISO C++ forbids declaration of 'shared_ptr' with no type /home/me/YADE/YADE201302/yade/core/ClumpTemplate.hpp:11: error: expected ';' before '<' token /home/me/YADE/YADE201302/yade/core/ClumpTemplate.hpp:12: error: field 'ct' has incomplete type /home/me/YADE/YADE201302/yade/core/ClumpTemplate.hpp:17: error: ISO C++ forbids declaration of 'Real' with no type /home/me/YADE/YADE201302/yade/core/ClumpTemplate.hpp:17: error: expected ';' before 'rad' /home/me/YADE/YADE201302/yade/core/ClumpTemplate.hpp:18: error: ISO C++ forbids declaration of 'Vector3r' with no type /home/me/YADE/YADE201302/yade/core/ClumpTemplate.hpp:18: error: expected ';' before 'pos' /home/me/YADE/YADE201302/yade/core/ClumpTemplate.hpp:20: error: return type specification for constructor invalid /home/me/YADE/working_on_trunk/core/ClumpTemplate.cpp:12: error: 'const int ClumpTemplate::ID_NONE' is not a static member of 'class ClumpTemplate' /home/me/YADE/working_on_trunk/core/ClumpTemplate.cpp:14: error: return type specification for constructor invalid /home/me/YADE/working_on_trunk/core/ClumpTemplate.cpp: In constructor 'ClumpTemplate::ClumpTemplate()': /home/me/YADE/working_on_trunk/core/ClumpTemplate.cpp:15: error: request for member 'id_ct' in 'this', which is of non-class type 'ClumpTemplate* const' /home/me/YADE/working_on_trunk/core/ClumpTemplate.cpp:16: error: returning a value from a constructor
make[2]: *** [CMakeFiles/core.dir/core/ClumpTemplate.cpp.o] Error 1
make[1]: *** [CMakeFiles/core.dir/all] Error 2
make: *** [all] Error 2



Follow ups