У меня есть следующая проблема: Эта ошибка появилась для меня, когда я скомпилировал исходный код:«Missing спецификатор типа INT предполагается» C++ Выпуск
error C4430: missing type specifier - int assumed
Эта ошибка возникает, когда переменная не инициализируется любой тип (например, целое число, float или любой пользовательский тип объекта). Но у меня есть тип, инициализированный, и он не распознается, хотя у меня есть больше классов, которые аналогично построены как проблема, и они работают нормально.
Итак, мой проблематичный класс является следующий:
class Rectangle
{
float x1, y1, x2, y2;
bool created;
public:
Rectangle() { created = false;}
Rectangle(float x1, float y1, float x2, float y2);
~Rectangle() {}
bool isCreated() { return created;}
void setCreated(bool c) { created = c;}
float getX1() { return x1;}
float getX2() { return x2;}
float getY1() { return y1;}
float getY2() { return y2;}
};
Пример рабочего класса:
class Triangle
{
private:
vector<float> x, y, z;
bool created;
public:
Triangle() { created = false;}
Triangle(vector<float> x, vector<float> y, vector<float> z);
~Triangle() {}
bool isCreated() { return created;}
void setCreated(bool c) { created = c;}
vector<float> getX() { return x;}
vector<float> getY() { return y;}
vector<float> getZ() { return z;}
};
Наконец, фрагмент кода, где происходят ошибки:
class Primitive
{
private:
string index;
Material mat;
Texture text;
int count;
Rectangle rect; //error detected in this line
Triangle tri;
Cylinder cyl;
Sphere sph;
Torus tor;
public:
Primitive() {count = 0;}
Primitive(string id, Material mt, Texture tx);
~Primitive(void);
string getIndex() { return index;}
Material getMaterial() { return mat;}
Texture getTexture() { return text;}
void addRectangle(float x1, float y1, float x2, float y2); //error detected in this line
Rectangle getRectangle() { if(rect.isCreated()) return rect; else return Rectangle(); } //error detected in this line
void addTriangle(float x1, float x2, float x3, float y1, float y2, float y3, float z1, float z2, float z3);
Triangle getTriangle() { if(tri.isCreated()) return tri; else return Triangle(); }
void addCylinder(float bs, float tp, float hei, int sli, int stac);
Cylinder getCylinder() { if(cyl.isCreated()) return cyl; else return Cylinder(); }
void addSphere(float rad, int sli, int stac);
Sphere getSphere() { if(sph.isCreated()) return sph; else return Sphere(); }
void addTorus(float in, float out, int sli, int loo);
Torus getTorus() { if(tor.isCreated()) return tor; else return Torus(); }
};
Есть идеи по их устранению?
EDIT: Мой включает в себя следующие:
#include "Material.h" //custom class
#include "Texture.h" //custom class
#include <iostream>
Компилятор Visual C++ 2010
.
какие у вас есть? –
Что это за компилятор? – Omnifarious