클래스 A에서 정적 함수를 만들고 클래스 B 함수에서 호출하려고 할 때 이상한 문제가 있습니다. 나는 얻다
`A :: funcA (int) '에 대한 정의되지 않은 참조
내 소스 코드는 다음과 같습니다. a.cpp
#include "a.h"
void funcA(int i) {
std::cout << i << std::endl;
}
아
#ifndef A_H
#define A_H
#include <iostream>
class A
{
public:
A();
static void funcA( int i );
};
#endif // A_H
b.cpp
#include "b.h"
void B::funcB(){
A::funcA(5);
}
그리고 bh
#ifndef B_H
#define B_H
#include "a.h"
class B
{
public:
B();
void funcB();
};
#endif // B_H
Code :: Blocks로 컴파일하고 있습니다.
#include "a.h"
void funcA(int i) {
std::cout << i << std::endl;
}
해야한다
#include "a.h"
void A::funcA(int i) {
std::cout << i << std::endl;
}
funcA
클래스의 정적 함수 이기 때문 입니다 A
. 이 규칙은 정적 및 비 정적 메서드 모두에 적용됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다