아래 코드는 현재 작업하고있는 코드의 일부입니다. 나머지는 내 문제와 관련이 없습니다. 정보 combineInfo (정보 a1) 멤버 함수에 문제가 있습니다. 이 범위에서 선언이 아니라고 오류. 내가 원하는 모든 정보를 결합하여 새로운 변수를 설정됩니다. 나는 성공적 구조를 사용하여이 할 수 있었다 지금은 자기 학습 클래스입니다.C++ 멤버 함수 선언 문제
#include <iostream>
#include <string>
using namespace std;
struct Date
{
int month;
int day;
int year;
};
class Information
{
public:
Information();
void printinformation();
Information combineInfo(Information a1);
//Setters and Getters Here
private:
string a;
double b;
double c;
Date d;
Date e;
};
void initializeDate(Date& d);
void printDate(Date& d);
int main()
{
cout << endl << "Now please input Information #1" << endl;
Information a1; // prompts for all the inputs for a1
cout << endl << "Now please input Information #2" << endl;
Information a2; // prompts for all the inputs for a2
a2.combineInfo(a1); // again prompts for info??
cout << "The combined Information is: " << endl;
info.printinformation();
return 0;
}
Information::Information()
{
string a;
cout << "Please enter a"<<endl;
getline(cin, a);
cout <<"Please enter b?"<<endl;
cin >> b;
getline(cin, dummy);
cout <<"Please enter c?"<<endl;
cin >> c;
getline(cin, dummy);
cout << "Please input the info start dates."<< endl;
initializeDate(start);
cout << "Please input the info end dates."<< endl;
initializeDate(finish);
}
Information Information::combineInfo(Information a1)
{
Information a1;
Information a2;
Information info;
a1.a = a2.a;
//etc.
return info;
}
죄송합니다, 오타 -하지만 근본 문제가 해결되지 않습니다. –