Reputation: 147
I described class in different files:
3DObjectDescription.h
#pragma once
#include <SFML/Graphics.hpp>
#include <NumCpp.hpp>
#include "MoveMatrix.h"
class Object3D
{
public:
nc::NdArray<float> vertexes;
nc::NdArray<float> faces;
Object3D();
void translation(float tX, float tY, float tZ);
void rotate_x(float angle);
void rotate_y(float angle);
void rotate_z(float angle);
void scale_(float scale_c);
};
3DObjectDescription.cpp
#include "3DObjectDescription.h"
Object3D::Object3D()
{
vertexes = {{0,0,0,1}, {0,1,0,1}, {1,1,0,1}, {1,0,0,1},
{0,0,1,1}, {0,1,1,1}, {1,1,1,1}, {1,0,1,1}};
faces = {{0,1,2,3}, {4,5,6,7}, {0,4,5,1}, {2,3,7,6}, {1,2,6,5}, {0,3,7,4}};
}
Object3D::translation(float tX, float tY, float tZ)
{
vertexes = nc::dot(vertexes, translate(tX, tY, tZ));
}
Object3D::rotate_x(float angle_)
{
vertexes = nc::dot(vertexes, rotation_X(angle_));
}
Object3D::rotation_y(float angle_)
{
vertexes = nc::dot(vertexes, rotation_Y(angle_));
}
Object3D::rotation_z(float angle)
{
vertexes = nc::dot(vertexes, rotation_Z(angle_));
}
Object3D::scale_(float scale_c)
{
vertexes = nc::dot(vertexes, scale(scale_c));
}
When I compiling it, I get errors:
error: no declaration matches 'int Object3D::translation(float, float, float)'
error: no declaration matches 'int Object3D::rotate_x(float)'
error: no declaration matches 'int Object3D::rotation_y(float)'
error: no declaration matches 'int Object3D::rotation_z(float)'
error: no declaration matches 'int Object3D::scale_(float)'
I dont know from where did the integer type come from, when I didnt declared it! And I had never met such error!
Upvotes: 1
Views: 23781
Reputation: 2834
The declaration return type is void
.
void translation(float tX, float tY, float tZ);
^^^^
But your definition does not have a type.
void Object3D::translation(float tX, float tY, float tZ)
^^^^ is missing
e.g. VS2019 error:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Upvotes: 3
Reputation: 14423
All of the definitions in 3DObjectDescription.cpp
are missing return types in their signatures.
Simply update their signatures to include the void
return type. The definition for Object3D::translation
should read
void Object3D::translation(float tX, float tY, float tZ)
{
vertexes = nc::dot(vertexes, translate(tX, tY, tZ));
}
Likewise for the rest.
The reason that your compiler is complaining about mismatched signatures instead of indicating a syntax error is because your compiler is implicitly assuming a return type of int
when none is specified. This is a holdover from C. However, this idiosyncrasy was removed in C++, so your compiler is exhibiting non-standard behavior by attempting to compile it.
Upvotes: 2