c++ 에서 class선언부를 헤더파일로,
그리고 main부분과 class 함수 부분을 cpp파일로 만들어서 동작시키려고 하는데,
Multiply defined 오류 발생해요..
프로젝트를 다시 생성도 해보고, 검색도 해봤는데, 도저히 모르겠어요..ㅠㅠ
===============================================================================
헤더파일
#pragma once
#include <iostream>
using namespace std;
ostream &oth(ostream &stream)
{
stream.width(2);
stream.fill(' ');
return stream;
}
class Othello
{
private:
int Board[8][8];
public:
Othello()
{
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
Board[i][j] = 0;
Board[3][3] = Board[4][4] = 1;
Board[4][3] = Board[3][4] = 2;
}
void print_board();
};
=============================================================================
함수부
#include "othello.h"
void Othello::print_board()
{
cout << oth << " ";
for (int x = 0; x < 8; x++)
cout << oth << x + 1;
cout << endl;
for (int y = 0; y < 8; y++)
{
cout << oth << y + 1;
for (int x = 0; x < 8; x++)
{
if (Board[y][x] == 0)
cout << oth << " ";
else if (Board[y][x] == 1)
cout << oth << "O";
else
cout << oth << "X";
}
cout << endl;
}
}
======================================================================================
메인부
#include "othello.h"
int main(void)
{
Othello othello;
othello.print_board();
return 0;
}
=======================================================================================
오류
cout << oth가 문제
cout랑 함수갖고 op<<호출하는코드라
ㄴ 아아아 그렇군요. 감사합니다!!! 고칠 부분조차도 몰랐는데, 이제 좀 손대볼수 있겠네요 ㅠㅠ
oth(cout) << str이런느낌으로 해보셈
ㄴ 넵넵 감사합니다! 사랑합니다! 복 많이 받으시고 ! 새해 복도 많이 받으세여!