-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
질문사항 있습니다..동작을 안하고 있어요..
24.04.16 10:00 작성 조회수 48
0
fun.cpp 를 만든 뒤에는 indef.cpp(main.cpp 역할) 가 동작을 안하고 있는 상태입니다.
undefined reference to 'display(MyStruce&)' 라는 오류가 뜨고 있습니다..
indif.cpp
undefined reference to 'display(MyStruce&)' 라는 오류가 뜨고 있습니다..
indif.cpp
#include "struct.h"
/*
1. 함수 원형
2. #define 이나 const를 사용하는 기호 상수
3. 구조체 선언
4, 클래스 선언
5. 탬플릿 선언
6. 인라인 함수
*/
int main() {
MyStruct PenguinCoding = {
"Penguin",
26,
};
display(PenguinCoding);
return 0;
}
fun.cpp#include "struct.h"
void display(MyStruct& temp) {
cout << "이름 : " << temp.name << endl;
cout << "나이 : " << temp.age << endl;
}
struct.h#ifndef STRUCT_H
#define STRUCT_H
#include <iostream>
//헤더 파일을 여러 파일에 포함시킬 때에,
//반드시 단 한 번만 포함시켜야 한다.
using namespace std;
struct MyStruct
{
string name;
int age;
};
void display(MyStruct& temp);
#endif
분명 정상적으로 따라가고 있었다고 생각했는데 어디에서 문제가 되는지 모르겠습니다..
답변을 작성해보세요.
0
gmjjb0309
질문자2024.04.16
fun.cpp 를 include 로 추가해주니까 정상 동작 하네요..?
#include "fun.cpp" 를 추가하고 나서야 동작이 되고 있습니다..
제가 이상한건가요? 아니면 누락된건가요?
0
답변 2