错误:预期';'在 '{' 标记之前 - 原因是什么? [英] error: expected `;' before '{' token - What is the cause?
本文介绍了错误:预期';'在 '{' 标记之前 - 原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的实现文件:
using namespace std;
#include <iostream>
#include <iomanip>
#include <string>
#include <stack> //line 5
#include "proj05.canvas.h"
//----------------Constructor----------------//
Canvas::Canvas() //line 10
{
Title = "";
Nrow = 0;
Ncol = 0;
image[][100]; // line 15
position.r = 0;
position.c = 0;
}
//-------------------Paint------------------// line 20
void Canvas::Paint(int R, int C, char Color)
{
cout << "Paint to be implemented" << endl;
}
我得到的错误是:
proj05.canvas.cpp: In function 'std::istream& operator>>(std::istream&,
Canvas&)':
proj05.canvas.cpp:11: error: expected `;' before '{' token
proj05.canvas.cpp:22: error: a function-definition is not
allowed here before '{' token
proj05.canvas.cpp:24: error: expected `}' at end of input
proj05.canvas.cpp:24: error: expected `}' at end of input
这些看起来像是简单的语法错误,但我不确定是什么问题.有人可以为我解码这些吗?我真的很感激,感谢您的时间!
These seem like simple syntax errors, but I am not sure what's wrong. Could someone decode these for me? I'd really appreciate it, thanks for your time!
编辑
这是我的 .h 文件中 Canvas 的定义:
Here is the definition of Canvas in my .h file:
#ifndef CANVAS_H
#define CANVAS_H
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
class Canvas
{
public:
Canvas(); void Paint(int R, int C, char Color);
const int Nrow;
const int Ncol;
string Title;
int image[][100];
stack<int> path;
struct PixelCoordinates
{
unsigned int r;
unsigned int c;
} position;
};
#endif
推荐答案
"proj05.canvas.h"
我敢打赌问题就在那里.也许没有 ;课后定义
"proj05.canvas.h"
i bet the problem is there. may be no ; after class def
这篇关于错误:预期';'在 '{' 标记之前 - 原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文