我似乎无法弄清楚为什么这不起作用.我试图建立一个指针类型的队列,但它失败了.我有一个教室,我想要排队指向Room ..所以我做了:
queue<*Room> bfsRooms;
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
`*'不能出现在常量表达式中
这是否意味着不可能创建指针的STL队列?
我正在研究Java中数据结构的这一部分,而我仍然对如何使用它们而不是数据结构以及为什么要使用它们感到困惑。
所以我很困惑,需要一个建议.在Java中,我可以实现自己的Stack,或者我可以使用java.util提供的Stack.
手册:
public class stack {
private int maxSize; //max size of stack
private char[] stackArray;
private int top; //index poistion of last element
public stack(int size){
this.maxSize=size;
this.stackArray=new char[maxSize];
this.top=-1; //
}
public void push(char j){
if (isFull()) {
System.out.println("SORRY I CANT PUSH MORE");
}else{
top++;
stackArray[top]=j;
}
}
public char pop(){
if(isEmpty()){
System.out.println("Sorry I cant pop more!");
return '0';
}else{
int oldTop=top;
top--;
return stackArray[oldTop];
}
}
public char peek(){
if(!isEmpty()) {
return stackArray[top];
}
}
public boolean …Run Code Online (Sandbox Code Playgroud) 这应该将我的输入保存到另一个txt文件.程序将询问您的txt文件的名称.
FILE *save;
char filename[100];
scanf ("%s", filename);
save = fopen ("filename", "w");
current = head;
while (current != NULL)
{
fprintf (save, " %s %s %d", current -> name, current -> tel, current -> age);
current = current -> next;
}
fclose(save);
Run Code Online (Sandbox Code Playgroud)
谁能告诉我我的错误?