#include "cs163hw1.h"
extras::extras(int num_cats){
head = new category_node;
head->next = NULL;
head->category = num_cats;
category_node * temp;
for(int i = 1; i < (num_cats); ++i){
temp = new category_node;
temp->next = head;
head = temp;
head->category = (num_cats-i);
}
}
extras::~extras(){
category_node * temp;
while(head->next){
temp = head;
head = head->next;
delete temp;
}
delete head;
}
extras::int print_cats(){
category_node * current;
while(current){
cout << current->category << endl;
current = current->next;
}
return 1;
}
print_cats 전에 int에서 식별되지 않은 식별자 오류가 발생합니다. C++을 사용한 이후로 잠시 지났지 만 ";"이 부족하다는 것을 기억합니다. 오류,하지만 내 인생에 나는 그것을 발견하지 못했습니다.C++ 예기치 않은 식별자
'int extras :: print_cats()'를 원하셨습니까? 더블 콜론 (범위 분석 연산자)은 한정적으로 사용되며,'print_cats'는'int'가 아닌 정규화가 필요한 것이다. – chris
맞아요, 주문을 잊었어요, 고마워요! – Flexo1515
잘 모르겠지만 category_node는 유형이므로 category_node * current; 초기화하지 않은 포인터를 선언하고 다음 줄에서도 사용합니다. 동안 (현재) – EddieV223