에러가 뜹니다 봐주세요 ㅠㅠ
다흰
프로그램은 2-d 백터의 덧셈 뺄샘 곱셈 과 복소수의 덧셈 뺄셈 곱셈을 구하는 겁니다...
//////////////// 이 표시가 에런데 왜 에러가 뜨는지 잘 몰겠네요..
#includeiostream
using namespace std;
class GenVec
{
public:
tdvector(float x1=0,float y1=0,float x2=0,float y2=0); /////// error(ISO C++ forbids declaration of ?dvector?with no typ)
void vectoradd();
void vectorSubtrct();
void print();
virtual void VecMultiply()=0;
public:
float v1[2];
float v2[2];
float add[2];
float sub[2];
float mult[2];
};
class Complex: public GenVec
{
public:
Complex(float x1=0,float y1=0,float x2=0,float y2=0);
void VecMultiply();
void print();
};
class TdVector: public GenVec
{
public:
void VecMultiply();
};
int main()
{
float x1,y1,x2,y2;
cout Enter the first two numbers: endl;
cin x1 y1;
cout Enter the next two numbers: endl;
cin x2 y2;
cout endl;
Complex c1;
TdVector t1;
c1.vectoradd();
c1.vectorSubtrct();
c1.VecMultiply();
c1.print();
t1.vectoradd();
t1.vectorSubtrct();
t1.VecMultiply();
t1.print();
}
GenVec::tdvector(float x1,float y1,float x2,float y2) /////////// same error
{
for(int i=0; i2; i++)
{
v1[0]=x1;
v1[1]=y2;
v2[0]=x2;
v2[1]=y2;
}
}
Complex::Complex(float x1,float y1,float x2,float y2):tdvector(x1,y2,x1,y2) ////////// error (class ?omplex?does not have any field named ?dvect)
{
}
void GenVec::vectoradd()
{
for (int i=0; i2; i++)
add[i]=v1[i]+v2[i];
}
void GenVec::vectorSubtrct()
{
for (int i = 0; i 2; i++)
sub[i] = v1[i] - v2[i];
}
void GenVec::print()
{
cout Two vectors result endl;
cout Addition: add[0] , add[1] endl;
cout Subtraction: sub[0] , sub[1] endl;
cout Dot product: mult[0] endl;
cout endl;
}
void Complex::VecMultiply()
{
mult[0] = ((v1[0] * v2[0]) + (v1[1] * v2[1]));
}
void Complex::print()
{
cout Two complex number results endl;
cout Addition: add[0] + add[1] i endl;
cout Subtraction: sub[0] + sub[1] i endl;
cout Multiplication: mult[0] + mult[1] i endl;
}