C++ 클래스에 관한 질문입니다.
바닐라
//////////////////////////////////////
#includeiostream
using namespace std;
class vector1
{
public:
void readin();
void vectorsum();
void dotproduct();
void printout();
private:
float a[3];
float b[3];
float c[3];
float dotprod;
};
void vector1::readin()
{
for(int i=0; i3; i++)
scanf(%f %f, &a[i],&b[i]);
}
void vector1::vectorsum()
{
for(int i=0; i3; i++)
c[i]=a[i]+b[i];
}
void vector1::dotproduct()
{
dotprod=0;
for(int i=0; i3; i++)
dotprod=a[i]*b[i];
}
void vector1::printout()
{
int i;
printf(The vector a is:\n);
for(int i=0; i3; i++)
printf(%f ,a[i]);
cout endl;
}
int main()
{
vector1 v1;
printf(Please enter the vectors a,b \n);
v1.readin();
v1.vectorsum();
v1.dotproduct();
v1.printout();
return 0;
}
/////////////////////////////////
제가 아주 초짜라서 그러는데 중간 중간에 :: 이건뭔가요.. 그리고
scanf(%f %f, &a[i],&b[i]); 이부분이 이해가 안합니다. %f는 뭐고 왜 a[i]앞에 & 붙여져있는지....
그리고 private 에 있는 a[3] b[3] 괄호가 뭘의미하는지도 몰겠구요
그리고 또한 마지막 부분 int main()에서부터
끝부분까지도 이해가 안가구요... printf()랑 scanf() 대해서도 갈쳐주세요.