2011-11-28 4 views
2

이 클래스의 포인터 동적 배열을 가리키는 클래스에 대한 포인터를 만들었습니다. 내가 만든 클래스의 함수 (Student)를 사용하려고합니다.이중 포인터에서 함수 호출

Student **list; 

list[i] = TextToClass(tempCourse); 
list[i].SetCourse(x); 
list[i].SetGrades(inFile); 

할당이 작동합니다. 그러나 이러한 기능을 사용하는 것은 효과가 없습니다. 기능을 사용하려면 어떻게해야합니까?

list[i] 무엇
student.cpp: In member function ‘void Controller::ReadAndStore()’: 
student.cpp:119: error: request for member ‘SetCourse’ in ‘((Controller*)this)->Controller::list[i]’, which is of non-class type ‘Student*’ 
student.cpp:121: error: request for member ‘SetGrades’ in ‘((Controller*)this)->Controller::list[i]’, which is of non-class type ‘Student*’ 
+0

[샘플 코드] (http://sscce.org/)는 간결하고 간결해야합니다. – outis

+2

질문을 게시 할 때 항상 "doe1s not work"를 정의하십시오. 컴파일 오류? 런타임 에러? 런타임 오류 : 예상되는 동작입니까? 실제 행동? –

답변

2

시도해 보셨습니까? Student **list로서

list[i]->SetCourse(x); 
list[i]->SetGrades(inFile); 
2

: 여기

오류인가? 어쩌면 그것의 포인터가 있다면, 당신은 사용해야한다. list[i] -> SetCourse(x);?

의도 한 바를 설명하는 대신 코드를 게시하는 것을 부끄러워하지 마십시오. 그것이 당신이 의도 한 것을한다면 당신은 질문하지 않을 것입니다.

2

포인터되어야 다음 포인터 포인터 및리스트 [I]이다. 그래서 그 메소드는 위의 답처럼 "->"표기법에 의해 호출되어야합니다.

관련 문제