Jump to content

Constructors with not defined parameters


photo

Recommended Posts

I have class:

class BaseObject
{
	private:
		Node node;
	public:
		BaseObject()
		{

		}

		~BaseObject() 
		{

		}

		void init(Node node)
		{
			this.node = node;

			node.setData(this);
		}

		string getName()
		{
			return node.getName();
		}

		Node getNode()
		{
			return node;
		}

		vec3 getPosition()
		{
			return node.getPosition();
		}

		vec3 getRotation()
		{
			return node.getRotation();
		}

		vec3 getScale()
		{
			return node.getScale();
		}

		void setName(string value)
		{
			node.setName(value);
		}

		void setNode(Node value)
		{
			if (node != NULL)
				node.setData(NULL);

			node = value;
			node.setData(this);
		}

		void setPosition(vec3 value)
		{
			node.setPosition(value);
		}

		void setRotation(vec3 value)
		{
			node.setRotation(value);
		}

		void setScale(vec3 value)
		{
			node.setScale(value);
		}

		void shutdown()
		{

		}

		void update(float dt)
		{

		}
};

and have next call:

BaseObject baseObject = new BaseObject(10, "---");

this cause error:

09:38:50 BaseObject baseObject = new BaseObject(10, "---");
09:38:50 source/maps/test.cpp:50: Parser::readName(): bad name '1'

this is right. But, if I don't declare default constructor, the error don't appear, and if we inherit BaseObject from, for example, TestClass and has constructor in it:

		TestClass()
		{
			// constructor without parameters
		}

the error don't appear too.

Link to comment
  • 2 months later...

If I define constructor in base class, and don't define it in derived class, then constructor don't call at all. Constructor in base class calls only if I define constructor in derived class too:

                       TestClass()
                       {
                               __BaseClass__();
                       }

 

Your Unigine script is more functional than OOP-oriented, I'm using Unigine more that half year, and during this time you did't do anything to improve you script OOP system, this is sad (

Link to comment
  • 4 weeks later...

If I define constructor in base class, and don't define it in derived class, then constructor don't call at all. Constructor in base class calls only if I define constructor in derived class too:

Fixed. Will be available in the next SDK update.

Link to comment
×
×
  • Create New...