0
Xcode에 따르면 내 주 파일에서 "stdDev"는 선언되지 않은 식별자이지만 헤더 파일에 선언되어 있습니다. 나는 이것을 완전히 고치는 방법을 태우고있다. 나는 약간의 원조를 바르게 평가할 것입니다!C++ 주 파일에 헤더 파일 (Xcode)에 선언되지 않은 식별자가 있습니다.
#include <iostream>
#include <string>
#include <cmath>
#include "Person.hpp"
using namespace std;
int main()
{
Person personRob("Rob", 95);
Person personBob("Bob", 89);
Person personGob("Gob", 99);
Person personArray[] = {personRob, personBob, personGob};
Person whole_class;
cout << "Standard deviation is: " << stdDev /* where Xcode is saying that stdDev is an undeclared identifier */ << endl;
return 0;
}
person.hpp는 :
#include <iostream>
#include <string>
#ifndef PERSON_HPP
#define PERSON_HPP
class Person
{
private:
std::string name;
double age;
public:
Person(std::string = " ", double = 0.0);
std::string getName();
double getAge();
double stdDev(Person personArray[], int size);
};
#endif
그것은 Person.hpp의 내용을 보지 않고 문제가 있는지 말해 어렵습니다 :로
그런 다음, 당신은 그것을 사용할 수 있습니다. –
헤더 파일을 추가했습니다. – midnightmerc
'stdDev'는 메소드입니다. 'Person' 인스턴스에서 호출해야합니다. 'cout << "표준 편차와 같은 것 :"<< whole_class.stdDev (더 많은 내용이 여기에 있습니다.) << endl; 그렇지 않으면 컴파일러는 당신이 찾을 수없는'stdDev'라는 이름의 변수가 있다고 생각합니다. – user4581301