|error: expected type-specifier before '(' token|

初学者的问题,在看视频的时候老师是可以运行的,但我用vs和codeblock都不能运行,代码我是照着打下来的,应该没错,那么这个是编译器问题还是我真的打错了....#include
using namespace std;

#include"string"
#include
#include
#include"set"
#include
#include"functional"

//函数对象
template
class show
{
public:
void operator(T &t)
{
cout << t << " ";
}

private:

};

void main()
{
cout << "hello wordl" << endl;
system("pause");
return 0;
}

1个回答

 void operator<<(T &t)
你运算符没写

你现在的水平是不可能遇到“编译器问题”的。

saber1043513213
saber1043513213 啊十分感谢,我当时看到您的评论点进去却发现被删除了,我以为是帖子被删除了,今天重新发帖才发现您的回复
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
error: expected ')' before '&' token
编译一个“约分分数为最简分式”程序时遇到 error: expected ')' before '&' tokenrn代码如下:rn[code=c]#include rnrn/* prototype */rnvoid reduce(int numerator, int denominator,rn int *reduced_numerator, int *reduced_denominator);rnrnint main(void)rnrn int m, n, reduced_m, reduced_n;rnrn printf("Enter a fraction: ");rn scanf("%d/%d", &m, &n);rnrn void reduce(m, n, &reduced_m, &reduced_n); //错误显示在这行rnrn printf("In lowest terms: %d/%d\n", reduced_m, reduced_n);rnrn return 0;rnrnrnvoid reduce(int numerator, int denominator,rn int *reduced_numerator, int *reduced_denominator)rnrn int mod, m, n;rnrn m = numerator;rn n = denominator;rnrn while (n != 0) rn mod = m % n;rn m = n;rn n = mod;rn rnrn *reduced_numerator = numerator / m;rn *reduced_denominator = denominator / m;rnrn[/code]
error: expected ‘)’ before ‘*’ token
我用gcc编译的时候出现了这样的错误,代码如下rnvoid addarpcache(u_int8_t *([color=#FF0000]出错点)[/color]ha,u_int8_t *pa)rnint checkarpcache(u_int8_t *([color=#FF0000]出错点[/color])ha,u_int8_t *pa)rnint arrayequal(u_int8_t *([color=#FF0000]出错点[/color])a,u_int8_t *b)rn这三个函数定义的地方都是这错误,是不是我写的形参格式不对呢?还是其他原因呢rn各位大侠帮帮忙看看哪。。。。。。。@~@rnrnrn
error: expected primary-expression before ‘*’ token
各位好,小弟初学c++在qt先编译这个函数的时候出现问题,请大家帮忙分析下。谢谢!~rnrnvoid ImageViewer::canny()rnrn const QImage * image;rn IplImage * pImg =NULL;rn IplImage * QImageToIplImage(const QImage * qImage);rn pImg = IplImage * QImageToIplImage(image);rn cvCanny(pImg, pCannyImg, 50, 150, 3);rnrn;rnrn编译时候这块出现rnI/usr/local/Trolltech/Qt-4.7.3/include -I/usr/local/include/opencv -I. -I../imageviewerCanny -I. -o imageviewer.o ../imageviewerCanny/imageviewer.cpprn[color=#FF0000]../imageviewerCanny/imageviewer.cpp: In member function ‘void ImageViewer::canny()’:rn../imageviewerCanny/imageviewer.cpp:303: error: expected primary-expression before ‘*’ token[/color]rnmake:离开目录“/root/桌面/imageviewer-build-desktop”rnmake: *** [imageviewer.o] 错误 1rnThe process "/usr/bin/make" exited with code %2.rnError while building project imageviewer (target: Desktop)rnWhen executing build step 'Make'[color=#FF0000][/color]
expected primary-expression before ']' token
以下代码:rnvoid function (char a[])rnint main()rnrn ......rn char a[20];rn function (a);rn ......rn return 0;rnrnrnvoidfunction (char a[])rnrn a[] = "jhbcakhba";rn ......rn return;rnrnrn为什么会出现RT的错误提示?错误行是" a[] = "jhbcakhba"; "rn求解啊
expected identifier before ‘(’ token
[code=C/C++]#include rn#include rn#include rn#include rn#include rn#include rnrn#define MAXDEFFER 1024rnint main(int argc,char *argv[])rnrn int fd,i;rn char buff[MAXDEFFER];rn if((fd=open(argv[1],O_RDONLY))==-1)rn perror("open");rn return 1;rn rn rn while(!fd.EOF)rn read(fd,buff,MAXDEFFER);rn printf("%s",buff);rn rn return 0;rn[/code]rnrn请问这是怎么一回事の~~~
expected initializer before '<' token
[code=C/C++]我用的是codeblocksrn// expected initializer before '<' token 下面这句编译出错了,不知道为什么?rn // 定义类型别名rn typedef std::vector VecType;rnrn//这道题是要传进迭代器,T应该就会实例化成为迭代器类型,为什么还可以这样子使用T::value_type呢?rn//迭代器里面也有value_type这个定义,value_type不是在容器里面的吗?》rn#include rn#include rn#include rn#include rn//using namespace std;rnrntemplate rntypename T::value_type MostFreq( T first, T last )rnrn // 计算需分配内存的大小rn std::size_t amount = 0;rn T start = first;rn while ( start != last )rn rn amount++;rn start++;rn rnrn // 定义类型别名rn typedef std::vector VecType;rnrn // 创建vector对象,用于保存输入序列的副本rn VecType vec(amount);rn VecType::iterator newFirst = vec.begin();rn VecType::iterator newLast = vec.end();rnrn // 将输入序列复制到vector对象rn std::uninitialized_copy( first, last, newFirst );rnrn std::sort ( newFirst, newLast ); // 对副本序列排序,使得相同的值出现在相邻位置rn std::size_t maxOccu = 0, occu = 0; // 出现最频繁的次数,当前值的出现次数rn VecType::iterator preIter = newFirst; //指向当前值的前一个值rn VecType::iterator maxOccuElement = newFirst; // 指向当前出现最频繁的值rnrn while( newFirst != newLast )rn rn if ( *newFirst != *preIter ) // 当前值与前一值不同rn rn if ( occu > maxOccu ) // 当前值的出现次数为目前最大次数rn rn maxOccu = occu; // 修改最大次数rn maxOccuElement = preIter; // 修改指向当前出现最频繁的值的迭代器rn rn occu = 0;rn rn ++occu;rn preIter = newFirst;rn ++newFirst;rn rn // 最后一个值的出现次数与目前的最大次数进行比较rn if ( occu > maxOccu )rn rn maxOccu = occu;rn maxOccuElement = preIter;rn rnrn return *maxOccuElement;rnrnrnrnint main ()rn rnrnrn return 0;rnrn[/code]
expected expression before ‘/’ token
int main(int argc, char* argv[])rnrn int width = 0;rn int height = 0;rn struct _LipStep1 * p_step1 = NULL;rn FtkWidget* win = NULL;rn FtkWidget* button = NULL;rn FtkWidget* img = NULL;rn FtkWidget* img_manager = NULL;rn PImgListManager p_manager = NULL;rn char file_name[128];rnrn p_step1 = malloc(sizeof(*p_step1));rn ret_val_if_fail(p_step1 != NULL, RET_FAIL);rn win = ftk_app_window_create();rn width = ftk_widget_width(win);rn height = ftk_widget_height(win);rnrn p_manager = img_list_create();rn snprintf(file_name,sizeof(file_name),"%s%s",DATA_DIR,"lip0.bmp"); //[color=#FF0000][/color expected expression before ‘/’ tokenrn rn img_list_insert(p_manager,img_list_ele_create(file_name));rn img = ftk_image_create(win, 300, 0, 100, 100);rn snprintf(file_name,sizeof(file_name),"%s%s",DATA_DIR,"step_1.bmp"); //[color=#FF0000][/color expected expression before ‘/’ tokenrn ftk_image_set_image(img,ftk_bitmap_factory_load(ftk_default_bitmap_factory(), file_name));rnrn p_step1->win = win;rn p_step1->img_manager = img_manager;rnrn button = ftk_button_create(win,310,height - 80,80,40);rn ftk_widget_set_text(button,"下一步");rn ftk_button_set_clicked_listener(button,button_winstep1_next,p_step1);rnrn button = ftk_button_create(win,310,height - 40,80,40);rn ftk_widget_set_text(button,"退出");rn ftk_button_set_clicked_listener(button,button_winstep1_quit,p_step1);rnrn ftk_widget_set_text(win,"唇彩试妆-步骤1");rn ftk_widget_show_all(win,1);rn ftk_widget_set_attr(win, FTK_ATTR_IGNORE_CLOSE);rnrn return RET_OK;rnrnrn错误有两处,已标出,请各位 高手帮帮忙啊。rn还有那个snprintf()函数的用法是怎么样的,怎么两个错误都 出现在那里呢?
expected unqualified-id before '->' token
最近在练习c++时,用c++的类来写一个双向循环链表,出现了以下错误,请问代码哪里错了[code=c]#ifndef L_I_N_K_P_S_Nrn#define L_I_N_K_P_S_Nrnrn#include rnrntemplate rnstruct node rn node(): prev(nullptr), next(nullptr), value(-1) ;rn node *prev, *next;rn datatype value;rn;rnrn//typedef node Node;rnrntemplate rnclass link rnpublic:rn typedef unsigned size_type;rn //link() = default;rn // link(initializer_list ls)rn link() = default;rnrn void insert(datatype t);rn node* search(datatype t);rn std::string deletes(datatype t);rnprivate:rn node nil;rn typename node::nil->prev = &nil, node::nil->next = &nil; //编译出来是这行错了,请问为什么rn; rn错误信息如下[code=c]error: expected unqualified-id before '->' tokenrn typename node::nil->prev = &nil, node::nil->next = &nil;[/code]rn#endif[/code]
局域网聊天室 error: expected class-name before '' token
准备用Qt Creator 编写一个简单的局域网聊天室,哪知刚开始就出现了错误 error: expected class-name before '' tokenrnrn头文件 tcpClientSocket.hrnrn#ifndef TCPCLIENTSOCKET_Hrn#define TCPCLIENTSOCKET_Hrn#include rn#include rnrnclass TcpClientSocket : public QTcpSocketrnrn Q_OBJECTrnpublic:rn TcpClientSocket(QObject *parent=0);rn ~TcpClientSocket();rnrn;rnrn#endif // TCPCLIENTSOCKET_Hrnrn源文件还没怎么写 tcpClientSocket.cpprnrn#include "tcpClientSocket.h"rnrnTcpClientSocket::TcpClientSocket(QObject *parent)rnrnrnTcpClientSocket::~TcpClientSocket()rnrnrnrnrn一但rebuild这个工程,就会出现rnerror: expected class-name before '' tokenrnrn大家帮我看看到底是什么原因,应该怎么处理?rn
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘’ token
hello.c code:rn#includernvoid mainrnrn printf("hello work!");rnrnrncompile:$ cc helloWork.crnhelloWork.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘’ tokenrnrnrnwhy??rn
C语言编译error:expected ')' before '*' token
[code=C/C++]rn/*************************************************************rn *rn * operate BitTreern *rn ************************************************************/rn#include rn#include rn#include rnrntypedef struct BitNodernrn char ele;rn struct BitNode *lchild;rn struct BitNode *rchild;rn*BitTree;rnrntypedef struct stackrnrn BitTree BTP;rn struct stack *next;rn*stackP;rnrnint i=0;rn//according to picture 6.8rnchar bitTreeArr[]='A','B','C','#','#','D','E','#','G','#','#','F','#','#','#';rnrnvoid FinOrderTraverse(BitTree p)rnrn if(p!=NULL)rn rn FinOrderTraverse(p->lchild);rn FinOrderTraverse(p->rchild);rn printf("%c ",p->ele);rn rnrnrn->void pushInStack(stackp *head,BitTree p)rnrn stackp sp;rn if((sp=malloc(sizeof(struct stack)))==NULL)rn rn printf("overflow,malloc failed in pushInStack.\n");rn exit(1);rn rn if(*head==NULL)rn rn *head=sp;rn rn elsern rn sp->next=*head;rn *head=sp;rn rnrnrn->void popStack(stackp *head,BitTree *p)rnrn stackp sp;rn sp=*head;rn *head=sp->next;rn *p=sp->BTP;rn free(sp);rnrnrnvoid MidInorderTraverse(BitTree p)rnrn stackP head=NULL;rn while(p!=NULL || head!=NULL)rn rn if(p)rn rn pushInStack(&head,p);rn p=p->lchild;rn rn elsern rn popStack(&head,&p);rn printf("%c ",p->ele);rn p=p->rchild;rn rn rnrnrnvoid MidOrderTraverse(BitTree p)rn rn if(p!=NULL)rn rn MidOrderTraverse(p->lchild);rn printf("%c ",p->ele);rn MidOrderTraverse(p->rchild);rn rnrnrnvoid PreOrderTraverse(BitTree p)rnrn if(p!=NULL)rn rn printf("%c ",p->ele);rn PreOrderTraverse(p->lchild);rn PreOrderTraverse(p->rchild);rn rnrnrnvoid createBitTree(BitTree *BT)rnrn if(iele=bitTreeArr[i];rn i++;rn createBitTree(&(*BT)->lchild);rn createBitTree(&(*BT)->rchild);rn rn rn rnrnrnint main()rnrn void createBitTree(BitTree *p);rn void PreOrderTraverse(BitTree p);rn void MidOrderTraverse(BitTree p);rn void FinOrderTraverse(BitTree p);rn ->void pushInStack(stackp *head,BitTree p);rn ->void popStack(stackp *head,BitTree *p);rn void MidInorderTraverse(BitTree p);rn BitTree head;rn createBitTree(&head); //create BitTreern rn printf("BitTree nodes print in preOrder are:");rn PreOrderTraverse(head); //preOrder traverse BitTreern printf("\n");rn rn printf("BitTree nodes print in midOrder are:");rn MidOrderTraverse(head); //midOrder traverse BitTreern printf("\n");rn rn printf("BitTree nodes print in finOrder are:");rn FinOrderTraverse(head); //finOrder traverse BitTreern printf("\n");rn rn printf("BitTree nodes print in midInOrder are:");rn MidInorderTraverse(head);rn printf("\n");rnrn[/code]rnrn编译时出错rnerror:expected ')' before '*' tokenrnrn出错行已在上面标示rn
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
编译时遇到这个错误,应该如何解呢
error: expected '=', ',', ';', 'asm' or '__attribute__' before '==' token
运算符重载rnboolean_t operator==(thread_t& thd_a, thread_t& thd_b)rnrn return (&thd_a == &thd_b);rnrnerror: expected '=', ',', ';', 'asm' or '__attribute__' before '==' tokenrnrn函数模板rnerror: expected '=', ',', ';', 'asm' or '__attribute__' before '<' tokenrntemplaternstatic inline void list_free(list_t* plst);rnrn代码明明没问题啊,这是怎么了?
error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
[code=C/C++]rnrn#ifndef _UT_TYPES_H_rn#define _UT_TYPES_H_rnrn#include rn#include rnrn// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$rn// $$$$$$$$$$$$$$$$$$$$common$$$$$$$$$$$$$$$$$$$$$rnrn#if defined WIN32 || WINCErn typedef __int64 S_INT64;rn typedef unsigned __int64 U_INT64;rn#define ATOI64(val) _atoi64(val)rn#elif defined (LINUX_PC) || defined (LINUX_PDA) || defined (ANDROID_PHONE) || defined (SYMBIAN_PHONE)rn typedef long long S_INT64;rn typedef unsigned long long U_INT64;rn #define ATOI64(val) strtoll(val, NULL, 10)rn typedef long long __int64;rn#endifrnrn#if defined WIN32 || WINCErn #define STDCALL __stdcall* rn#elif defined (LINUX_PC) || defined (LINUX_PDA) || defined (ANDROID_PHONE) || defined (SYMBIAN_PHONE)rn #define STDCALL *rn#endifrnrn#define MAXLEN_OF_PATH 256 // ¬∑æ∂◊Ó¥Û≥§∂»rnrnrn#define INrn#define OUTrn#define INOUTrnrntemplate rn提示rnut_types.h:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' tokenrnrnrnrnrn[/code]
[Error] expected '=', ',', ';', 'asm' or '__attribute__' before '' token
[img=https://img-bbs.csdn.net/upload/201710/03/1507041265_869989.png][/img]rn[img=https://img-bbs.csdn.net/upload/201710/03/1507041276_828324.png][/img]rn[img=https://img-bbs.csdn.net/upload/201710/03/1507041285_128912.png][/img]rn[img=https://img-bbs.csdn.net/upload/201710/03/1507041294_701851.png][/img]rnrn[Error] expected '=', ',', ';', 'asm' or '__attribute__' before '' tokenrn我找半天也没找到错误在哪里。。
错误:expected initializer before '.' token
在头文件中定义一个 全局变量static QMappooln在源文件函数中初始化pool QMap address_pool::pool.insert(i,IP);n然后就报错,大神们求解决,困恼了2天了
编译错误:expected template-name before ‘<’ token
template rnrnclass graphrnrnrnrn public:rnrn [color=#FF0000]class const_iterator: public map< T, int >::const_iteratorrn[/color]rn rnrn public:rn......rn红色的那行有错误,不知道为何?rn初学者,谢谢帮忙!rn
expected primary expression before '%' token
http://acm.hrbeu.edu.cn/index.php?act=problem&id=1001&cid=20rnrnValid date formatrnrncode:rn#includern#includernchar yuefen[13][5]="Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec";rnint getyue(char a[])rnrn int i,yue;rn for(i=0;i<12;i++)rn rn if(strcmp(a,yuefen[i])==0)rn rn yue=i+1;rn return yue;rn rn rn return -1;rnrnrnint leap(int y)rnrn if((y%4==0&&y%100!=0)||(y%400==0))rn return 1;rn else return 0;rnrnrnint judge(int m,int d,int y)rnrn if((y>1000)&&(m==1||m==3||m==5||m==7||m==8||m==10||m==12)&&(d>0&&d<=31))rn return 1;rn else if((y>1000)&&(m==4||m==6||m==9||m==11)&&(d>0&&d<=30))rn return 1;rn else if((y>1000)&&leap(y)==1&&m==2&&(d>0&&d<=29))rn return 1;rn else if((y>1000)&&leap(y)==0&&m==2&&(d>0&&d<=28))rn return 1;rn else return 0;rnrnrnint main()rnrn char str[50],yue[10];rn int d,m,y,flag;rn while(gets(str))rn rn if(str[2]=='-'&&str[5]=='-')rn rn sscanf(str,"%d-%d-%d",&m,&d,&y);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else if(str[2]=='-'&&(str[3]>='A'&&str[3]<='S'))rn rn sscanf(str,"%d-%[^-]-%d",%d,yue,&y); //明明照着书上敲的 咋编译错误啊rn m=getyue(yue);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else if(str[2]=='/'&&str[5]=='/')rn rn sscanf(str,"%d/%d/%d",&m,&d,&y);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else if(str[4]=='/'&&str[7]=='/')rn rn sscanf(str,"%d/%d/%d",&y,&m,&d);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else if(str[4]=='/'&&(str[5]>='A'&&str[3]<='S'))rn rn sscanf(str,"%d/%[^/]/%d",&y,yue,&d);rn m=getyue(yue);rn if(judge(m,d,y)==1)rn printf("%.2d-%.2d-%d\n",m,d,y);rn else printf("Invalid\n");rn rn else printf("Invalid\n");rn rn return 0;rnrnrnrn额 发现手残打错东西了···rn应该是&d····rn好吧 请问各位大神%[^-]是什么意思?rn以前从来都没见过
expected initializer before '<' token问题
#includernusing namespace std;rntemplaternstruct BiNodernrn DataType data;rn BiNode*lchild,*rchild;rn;rntemplaternclass BiTreernrn public:rn BiTree()root=Creat(root);rn rn ~BiTree()Release(root);rn rn void PreOrder()PreOrder(root);rn rn private:rn BiNode*root;rn BiNode*Creat(BiNode*bt);rn void Release(BiNode*bt);rn void PreOrder(BiNode*bt);rn;rntemplaternvoid BiTree::PreOrder(BiNode*bt)rnrn if(bt==NULL)return;rn elsern cout<data;rn PreOrder(bt->lchild);rn PreOrder(bt->rchild);rn rnrntemplatern[u][i]BiNode*Bitree::Creat(BiNode*bt)[/u]rnrn cin>>ch;rn if(ch=='#')bt=NULL;rn elsern bt=new BiNode;rn bt->data=ch;rn bt->lchild=Creat(bt->lchild);rn bt->rchild=CREAT(bt->rchild);rn rn return bt;rnrnmain()rnrn BiTree BT;rn BiNode*root;rn BT.PreOrder();rnrn错误是这个expected initializer before '<' token,rn这个是什么意思啊,怎么改rn错误在我下划线的位置
[Error] qualified-id in declaration before '(' token [Error] expected '' at end
#include rn#include rn#include rn#include rnusing namespace std;rnint N;rnclass studentrnrn public:rn void addstudent ();rn void deletestudent ();rn void findstudent ();rn void changestudent ();rn void writetofile ();rn void readfromfile ();rn void sumstudent (); rn private:rn long id;rn string name;rn string sex;rn string place;rn long telnum;rn string mail;rn rn;rnvoid student::addstudent()rnrn int i=0,t;rn cout<<"请输入要添加的人数"<>t;rn N=N+t;rn student stu[N];rn for(;i>stu[i].id>>stu[i].name>>stu[i].sex>>stu[i].place>>stu[i].telnum>>stu[i].mail;rn rnrnvoid student::deletestudent()rnrn string Name;rn int i=0,a=-1;rn cout<<"请输入要删除的学生名字"<>Name;rn student stu[N];rn for(;i>Name;rn int i=0;rn for(;i>Name;rn for(;i>a;rn while(1)rn rn switch(a)rn rn case 1:rn stu.readfromfile();rn break;rn case 2:rn stu.addstudent();rn break;rn case 3:rn stu.deletestudent();rn break;rn case 4:rn stu.findstudent();rn break;rn case 5:rn stu.changestudent();rn break;rn case 6:rn stu.sumstudent();rn break;rn case 7:rn stu.readfromfile();rn break;rn rn rnrnint main()rnrn menu();rn return 0;rn
Syntax error on token ")", ++ expected
An error occurred at line: 42 in the jsp file: /show.jsprnSyntax error on token ")", ++ expectedrn39: for(int i=0;i");rn43: out.println(""+myname_card.getID()+"");rn44: out.println(""+myname_card.getname()+"")rn45: out.println(""+myname_card.getsex()+"");
error: expected init-declarator before "GroupNameList_t"
下边的一行位于一个头文件的内容的第一行rn#include rnrn#include rn#include rn#include rnrn#include "Application.H"rnrntypedef std::vector GroupNameList_t;rnrn编译报错:rnerror: expected init-declarator before "GroupNameList_t"rnrn请达人指点。rnrn是与 #include "Application.H" 有关?
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘. '
在Suse11.0上用交叉编译器xscale-linux-gcc编译一个库,出现如题的错误:rn“rnxscale-linux-gcc -O2 -fPIC -I. -I ../../kernel -I ../lib -DHAVE_CONFIG_H -D_U_="__attribute__((unused))" -c bpf_filter.crnbpf_filter.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ tokenrnmake: *** [bpf_filter.o] Error 1rn”rnrnbpf_filter.c文件的内容就一行:rnlink ./bpf/net/bpf_filter.crnrn我一直用的C++编程,第一次看到这样的C语言代码,现在有两个问题:rn(1)这句话是什么意思?rn(2)上面的错误该如何解决rnrn希望高手能解答一下,谢谢! rn
error: expected ',' or '...' before numeric constant
union Argrnrn bool b;rn char c;rn WORD w;rn DWORD d;rn int i;rn float f;rn INT64* I;rn void* p;rn const char* s;rn ViPacket* m;rn uint64_t* U;rnrn Arg(bool _b) b = _b;rn Arg(char _c) c = _c;rn Arg(WORD _w) w = _w;rn Arg(DWORD _d) d = _d;rn Arg(int _i) i = _i;rn Arg(float _f) f = _f;rn Arg(INT64& _I) I = &_I;rn Arg(uint64_t& _U) U = &_U;rn Arg(void* _p) p = _p;rn Arg(string& _s) s = _s.c_str();rn Arg(const char* str) s = str;rn Arg(ViPacket& _m) m = &_m;rn;rn我想问一下为什么Arg(uint64_t& _U) U = &_U;这一行会报错误,谢谢各位
error: expected specifier-qualifier-list before ‘FF_COMMON_FRAME'
libavcodec/mpegvideo.h:83: error: expected specifier-qualifier-list before ‘FF_COMMON_FRAME’这个错误是怎么回事呢?
in function 'xx'; error : expected';' before ''
数据结构实验一 线性表的实现与多项式的加法rn 在codeblock下编译出错rn in function 'Add':rn error : expected';' before ''rn rn代码如下:rn#includern#includern#define ERROR 0rn#define OK 1rn#define Overflow 2rn#define Underflow 3rn#define Notpresent 4rn#define Duplicate 5rnrntypedef int Elemtype;rntypedef structrnrn int n;rn int maxLength;rn Elemtype *element;rnSeqList;rnrntypedef int Status;rnrnrntypedef struct PNodernrn int coef;rn int exp;rn struct PNode* link;rnPNode;rntypedef structrnrn struct PNode *head;rnpolynominal;rnrnrnrnStatus Init(SeqList *L,int mSize)rnrn L->maxLength=mSize;rn L->n=0;rn L->element=malloc(sizeof(Elemtype)*mSize);rn if(!L->element)rn return ERROR;rn return OK;rnrnrnStatus Find(SeqList L,int i,Elemtype *x)rnrn if(i<0||i>L.n-1)rn return ERROR;rn *x=L.element[i];rn return OK;rnrnrnStatus Insert(SeqList *L,int i,Elemtype x)rnrn int j;rn if(i<-1||i>L->n-1)rn return ERROR;rn if(L->n==L->maxLength)rn return ERROR;rn for(j=L->n-1;j>i;j--)rn L->element[j+1]=L->element[j];rn L->element[i+1]=x;rn L->n=L->n+1;rn return OK;rnrnrnStatus Delete(SeqList *L,int i)rnrn int j;rn if(i<0||i>L->n-1)rn return ERROR;rn if(!L->n)rn return ERROR;rn for(j=i+1;jn;j++)rn L->element[j-1]=L->element[j];rn L->n --;rn return OK;rnrnrnvoid Output(SeqList L)rnrn int i;rn //if(!L.n)rn //return ERROR;rn for(i=0;ihead=malloc(sizeof(PNode));rn p->head->exp=-1;rn p->head->link=NULL;rn for(;;)rn rn pn=malloc(sizeof(PNode));rn printf("coef:\n");rn scanf("%d",&pn->coef);rn printf("exp:\n");rn scanf("%d",&pn->exp);rn if(pn->exp<0) break;rn pre=p->head;rn q=p->head->link;rn while(q&&q->exp>pn->exp)rn rn pre=q;rn q=q->link;rn rn pn->link=q;rn pre->link=pn;rn rnrnrnrnrnvoid Add(polynominal *px,polynominal *qx)rnrn PNode *q,*q1=qx->head,*p,*temp;rn p=px->head->link;rn q=q1->link;rn while(p&&q)rn rn while(p->expexp)rn rn q1=q;rn q=q->link;rn rn if(p->exp==q->exp)rn rn q->coef=q->coef+p->coef;rn if(q->coef==0)rn rn q1->link=q->link;rn free(q);rn q=q1->link;rn p=p->link;rn rn elsern rn q1=q;rn q=q->link;rn p=p->link;rn rn rn elsern rn temp=malloc(sizeof(PNode));rn temp->coef=p->coef;rn temp->exp=p->exp;rn temp->link=q1->link;rn q1->link=temp;rn p=p->link;rn rn 1rnrnrnvoid main()rnrn int i,j,k,m,num,x,y;rn SeqList list;rn printf("请输入元素的最大空间:");rn scanf("%d",&m);rn Init(&list,m);rn printf("请输入元素的个数:");rn scanf("%d",&num);rn list.n=num;rn printf("请输入各个元素:");rn printf("\n");rn for(i=0;i
error: expected nested-name-specifier before 'writer_trait'
这是代码:rn[code=C/C++]template rnclass filer_traitrnrnpublic:rn typedef typename writer_trait writer_type;rn typedef typename reader_trait reader_type;rn;rnrn//This is a helper function, not part of the STL-SLrnint main() rn return 0;rnrn[/code]rnrnstl的源码中大量用到这种 typedef typename xxx yyy 的形式,为什么这里会报错?rnrn这是cmd的详细错误rn[code=C/C++]C:\Windows\system32\cmd.exe /c makern[100%] Building CXX object CMakeFiles/test.dir/test.cpp.objrnG:\workspace\test\test.cpp:12:19: error: expected nested-name-specifier before 'rnwriter_trait'rnG:\workspace\test\test.cpp:12:32: error: expected ';' before 'writer_type'rnG:\workspace\test\test.cpp:13:19: error: expected nested-name-specifier before 'rnreader_trait'rnG:\workspace\test\test.cpp:13:32: error: expected ';' before 'reader_type'[/code]
error: expected specifier-qualifier-list before 'list_head
我在学内核的方法做链表的时候,内现了一个错误,如题目所述。rnrn我在一个a.h文件里。rn定义了一个struct list_head struct list_head *pre, *next; rn然后在后面用了这个结构,在结构体A里引用 struct A struct list_head mmhead; ... ... 就出现如上错误。rnrn请问有没有那位高人以前碰到过类似的。rn在网上搜索很多都是与内核相关的,不过我的程序跟内核没有一点儿关系,只是学内核的方法来构建链表而已。结构是自己定义的。rn谢谢·
请教. 编译一直[Error] expected primary-expression before'*'token
#ifndef MAZE_CREATE_Hrn#define Maze_Create_Hrn#define ROWS 40 rn#define COLS 60rn#define DIRECTION_NUM 4rn#define DIRECTION_EAST 0rn#define DIRECTION_SOUTH 1rn#define DIRECTION_WEST 2rn#define DIRECTION_NORTH 3rn#includernusing namespace std;rntypedef struct cellrnrn bool door[DIRECTION_NUM];rncell;rnvoid create_Maze(int *cells, cell (*maze)[COLS]);rnstatic void init_Maze(int *cells, cell (*maze)[COLS]);rnstatic bool is_Connect(const int * const cells, int c1, int c2);rnstatic bool all_Connect(const int * const cells);rnstatic void union_Cells(int *cells, int c1, int c2);rn#endifrnrn/*rn* 迷宫实现类:Maze_Create.cpprn*/rn#includern#include rnrnint cells[ROWS*COLS];rncell maze[ROWS][COLS];rnvoid create_Maze(int *cells, cell (*maze)[COLS]) rnrn int direction, c1, c2;rn int CELL_NUM = ROWS*COLS;rn init_Maze(cells, maze);rn srand((unsigned)time(NULL));rn while(1)rn rn c1 = rand()%CELL_NUM;rn direction = rand()%DIRECTION_NUM;rn switch(direction)rn rn case DIRECTION_EAST:rn if(c1%COLS == COLS-1) c2 = -1;rn else c2 = c1 + 1;rn break;rn case DIRECTION_SOUTH:rn if((ROWS-1) == (c1 - c1%COLS)/COLS) c2 = -1;rn else c2 = c1 + COLS;rn break;rn case DIRECTION_WEST:rn if(c1%COLS == 0) c2 = -1;rn else c2 = c1 - 1;rn break;rn case DIRECTION_NORTH:rn if(0 == (c1 - c1%COLS)/COLS) c2 = -1;rn else c2 = c1 - COLS;rn break;rn default:rn printf("error on random numbers/n");rn exit(0);rn break;rn rn if(c2 < 0) continue;rn if(is_Connect(cells, c1, c2)) continue;rn elsern rn union_Cells(cells, c1, c2);rn maze[(c1-c1%COLS)/COLS][c1%COLS].door[direction] = true;rn maze[(c2-c2%COLS)/COLS][c2%COLS].door[(direction+2)%DIRECTION_NUM] = true;rn rn if(is_Connect(cells, 0, CELL_NUM - 1)) break; rn rnrnvoid init_Maze(int *cells, cell (*maze)[COLS])rnrn int i, j, k;rn for(i = 0; i < ROWS; i++)rn rn for(j = 0; j < COLS; j++)rn rn for(k = 0; k < DIRECTION_NUM; k++)rn maze[i][j].door[k] = false;rn rn rn maze[0][0].door[DIRECTION_WEST] = true;rn maze[ROWS-1][COLS-1].door[DIRECTION_EAST] = true;rnrn for(i = 0; i < ROWS*COLS; i++)rn rn cells[i] = -1;rn rnrnbool is_Connect(const int * const cells, int c1, int c2)rnrn while(cells[c1] >= 0) c1 = cells[c1];rn while(cells[c2] >= 0) c2 = cells[c2];rn if(c1 == c2) rn return true;rn else rn return false;rnrn/*rn* if the two adjacent rooms are not connect, remove the wall between them(or fix a door)rn*/rnvoid union_Cells(int *cells, int c1, int c2)rnrn while(cells[c1] >= 0) c1 = cells[c1];rn while(cells[c2] >= 0) c2 = cells[c2];rn if(cells[c1] > cells[c2])rn rn cells[c1] = c2; rn rn elsern rn if(cells[c1] == cells[c2]) cells[c1]--;rn cells[c2] = c1;rn rnrnbool all_Connect(const int * const cells)rnrn int i, count_root = 0;rn for(i = 0; i < ROWS*COLS; i++)rn rn if(cells[i] < 0) count_root++;rn rn if(1 == count_root) rn return true;rn else rn return false;rnrnint main()rnrn int *cells;rn create_Maze(cells,cell*maze[COLS]);rnrn一个生成迷宫的程序,函数已经写好了,但是主程序引用一直出错,暂时看不出怎么改,各位帮帮忙。
error: expected constructor, destructor, or type conversion before ‘(’ token
出现了很多同样的错误,错误定位在:rnDLLEXPORT_API int __stdcall GetVideoSignal(HANDLE hChannelHandle);rnDLLEXPORT_API int __stdcall GetSDKVersion(PVERSION_INFO VersionInfo);rnDLLEXPORT_API int __stdcall GetCapability(HANDLE hChannelHandle, CHANNEL_CAPABILITY *Capability);rnDLLEXPORT_API int __stdcall GetLastErrorNum(HANDLE hChannelHandle, ULONG *DspError, ULONG *SdkError);rnDLLEXPORT_API int __stdcall SetStreamType(HANDLE hChannelHandle, USHORT Type);rnDLLEXPORT_API int __stdcall GetStreamType(HANDLE hChannelHandle, USHORT *StreamType);rnDLLEXPORT_API int __stdcall GetFramesStatistics(HANDLE hChannelHandle, PFRAMES_STATISTICS framesStatistics);rnDLLEXPORT_API int __stdcall StartMotionDetection(HANDLE hChannelHandle);rnDLLEXPORT_API int __stdcall GetBoardInfo(HANDLE hChannelHandle, ULONG *BoardType, UCHAR *SerialNo);rnDLLEXPORT_API int __stdcall StopMotionDetection(HANDLE hChannelHandle);rnDLLEXPORT_API int __stdcall GetOriginalImage(HANDLE hChannelHandle, UCHAR *ImageBuf, ULONG *Size);rnDLLEXPORT_API int __stdcall RegisterLogRecordCallback(LOGRECORD_CALLBACK LogRecordFunc, void *Context);rnDLLEXPORT_API int __stdcall SetAudioPreview(HANDLE hChannelHandle, BOOL bEnable);rn还有很多,请帮忙哦!谢谢!
C语言错误 [Error] expected primary-expression before ')' token
编写一函数,判断一字符串是否为回文。所谓“回文”是指顺读和倒读都一样的字符串,如“deed”和“level”是回文。在主函数中对输入的5个字符串统计其中回文的个数。rn#includern#includernint main()rn int HW(char str[]);rn char str[5][80];rn char string[80];rn int i,s=0;rn printf("Please enter 5 string:\n");rn for (i=0;i<5;i++)rn scanf("%s",str);rn [color=#FF0000]if(HW(str*))[/color]rn s=s+1;rn printf("回文字符串有%d个",s);rn rnrnrnint HW(char str[])rnrn int i; rn int L=strlen(str);rn for(i=0;i
[Error] expected primary-expression before ']' token出现这样的错误为什么
#include "findAlgorithm.h"rntemplate rn/***************************************************rn普通查找normal_find(数组名,所查找对象) rn***************************************************/rnint FindAlgorithm::normal_find(Keytype key[],Keytype find_obj)rnrn int length_of_key=sizeof(key);rn int i;rn for( i=0;irnint FindAlgorithm::half_find(Keytype key[],Keytype find_obj,int head,int end,int rise_or_descend)rnrn if(head>end)rn return -1;rn else if(key[(head+end)/2]==find_obj)rn return (head+end)/2;rn else if(key[(head+end)/2]>find_obj)rn rn if(rise_or_descend==1)rn half_find(key[],find_obj,head,(head+end)/2-1,1);rn elsern half_find(key[],find_obj,(head+end)/2+1,end,2);rn rn elsern rn if(rise_or_descend==1) rn half_find(key[],find_obj,(head+end)/2+1,end,1);rn elsern half_find(key[],find_obj,head,(head+end)/2-1,2);rn rn
单链表的实现中出现error: expected ';', ',' or ')' before '&' token的错误
[code=c]#include rn#include rnrntypedef int ElemType;rnrntypedef struct LNodern ElemType data;//数据域rn struct LNode *next; //指针域rnLNode, *LinkList;rnrn//初始化线性表rnvoid Init_LinkList(LinkLinst &L)rn L = (LinkList)malloc(sizeof(LNode));rn L->next = NULL;rn rnrn//取元素rnint GetElem_LinkList(LinkList &L, int i, Elemtype e)rn //L是带头结点的链表的头指针,以e返回第i个元素rn p = L->next;//p指向第一个节点rn j = 1;//j为记数量rn while(p&&j<1)//顺时针向后查找,直到p指向第i个元素rn p = p->next;rn ++j;rn rn if(!p||j>i)//如果p不存在rn return 0;rn rn elsern e = p->data;rn return 1;rn rnrnrn//插入数组元素rnint Insert_LinkList(LinkList &L, int i, ElemType e)rn p = L->next;rn j=0;rn while(p&&jnext;rn ++jrn rn if(!p||j>i-1)//插入位置非法rn return 0;rn rn elsern s=(LinkList)malloc(sizeof(LNode));rn s->data = x;rn s->next = p->next;rn p-next = s;rn return 1;rn rn rnrn//删除元素rnint Delete_LinkList(LinkList &L, int i, ElemType e)rn p = L->next;rn j=1;rn while(p&&jnext;rn ++j;rn rn if(!p||j>i-1)rn return 0;rn rn elsern q=p->next;rn p->next=q->next;rn e = q->data;rn free(q);rn return 1;rn rnrn//建立线性表rn//头插法:rnvoid CreatLinkList(LinkList &L, int n)rn L=(LinkList *)malloc(sizeof(LinkList);rn //创建头结点rn L->next=NULL;rn for(i=n;i>0;i--)rn p=(LinkList *)malloc(sizeof(LNode));rn scanf(&p->data);rn p->next = L->next;rn L->next = p;rn rnrnrn//线性表的合并rnvoid Merge_L(LinkList &La, LinkList &Lb, LinkList &Lc)rn//按值排序的单链表La,Lb,归并为Lc后也按值排序rn pa = La->next;rn pb = Lb->next;rn Lc = pc = La;//初始化rn while(pa&&pb)//将pa,pa结点按大小依次插入c中rn if(pa->data<=pb->data)rn pc-next=pa;rn pc= pa;rn pa=pa->next;rn elsern pc->next = pb;rn pc = pb;rn pb = pb->next;rn rn pc -> next =pa?pa:pb;//插入剩余值rn free(Lb);rn rnrn rnrnrnrnrnrnrnrnrn[/code]rnrnrn出现相同的错误:rnmain.c|12|error: expected ')' before '&' token|rnmain.c|18|error: expected ';', ',' or ')' before '&' token|rnmain.c|36|error: expected ';', ',' or ')' before '&' token|rnmain.c|56|error: expected ';', ',' or ')' before '&' token|rnrn求助
[C语言]expected identifier or ‘(’ before ‘’ token
[code=c]#include rn#include rn /*报错行:expected identifier or ‘(’ before ‘’ token */rn char i[6];rn scanf("%s",i);rn int c = strlen(i);rn printf("%d",c);rn int a = 0;rn while(a!=c)rn rn if(a!=0)rn printf(" ");rn printf("%c",i[a]);rn a++;rn rn return 0;rnrn [/code]rn作用是想让输入的字符倒叙输出.rn 环境:linux 3.10.0-693.11.6.el7.x86_64 gcc 4.8.5 20150623 (Red Hat 4.8.5-16)rn
Syntax error on token "", expected after this token
我的程序老是报这样的错,我应该怎么办?急!rnimport java.awt.*;rnimport java.awt.event.*;rn//import java.applet.*;rn//import javax.swing.ImageIcon;rnimport javax.swing.*;rnimport java.io.*;rnrn//画布,运行中图画部分rnclass Imagecanvas extends Canvas rn private static final long serialVersionUID = 1L;//保证兼容性rn Toolkit tool;//工具箱rn Image Im;//图像rnrn Imagecanvas() rn setSize(300, 50);rn tool = getToolkit();//返回窗体工具包rn Im = tool.getImage("dj.jpg");rn rnrn public void paint(Graphics g) rn g.drawImage(Im, 0, 0, 150, 50, this);//在画布上g上画图片Im坐标为(0,0),Graphics.top为360,Graphics.left为50rn rnrnrn//按钮rnclass GongNeng extends JFrame implements ActionListener rn private static final long serialVersionUID = 1L;rnrn GongNeng() rn super("车辆管理");rn setSize(250, 200);//大小rn setLocation(250, 120);//位置rn setResizable(false);//窗口大小是否可改变rn JPanel p1 = new JPanel();//图片区rn JPanel p2 = new JPanel();rn JPanel p3 = new JPanel();rnrn Imagecanvas canvas1 = new Imagecanvas();rn p1.setSize(300, 150);rn p1.add(canvas1);rn rn p2.setBounds(70, 70, 200, 80);rn p2.setLayout(new GridLayout(2, 1, 5, 5));rn JButton number = new JButton("车辆信息");rn JButton create = new JButton("新建");rn Container c = getContentPane();rn c.setLayout(null);rn p2.add(number);rn p2.add(new JLabel(" "));rn p2.add(create);rn rn add(BorderLayout.NORTH, p1);rn add(BorderLayout.CENTER, p2);rn add(BorderLayout.SOUTH, p3);rn this.setVisible(true);rn rn rn public void actionPerformed(ActionEvent e) rnrn rnrnrn class BaoCun extends WindowAdapter implements ActionListenerrn Frame f;rn Button btn;rn //TextArea ta;rn String fileName;rn public class XinJianrn this.fileName=fileName;rn f=new Frame();rn f.addWindowListener(this);rn TextField ta =new TextField(25);rn btn=new Button("保存");rn btn.addActionListener(this);rn //ta=new TextArea(60,60);rn f.add(ta,BorderLayout.CENTER);rn f.add(btn,BorderLayout.SOUTH);rn f.pack();rn f.setVisible(true);rn //new XinJian();rn rn rn public void actionPerformed(ActionEvent e) rn if(e.getActionCommand().equals(btn))rn new XinJian(); rn rn rn rnrnpublic class GuanLi rn public static void main(String[] args) rn new GongNeng(); rn rnrnrn如果可以的话,希望能帮我弄成可执行的,我是新手,谢谢帮忙!
expected primary-expression before ']' token大神帮帮忙
#include"stdio.h"rn#include"stdlib.h"rnrnvoid select_sort(int a[],int n)rn//将a中的数按从小到大排列 rnrn int temp,j,i,k;rn for(i=0;i
NDK编译出现expected ‘;’, ‘,’, ‘;’before ‘<’ token
我在ndk下编译c库到android中去,出现下面的错误,网上找了发现都不是我的这个问题啊 有遇到过得没有?[img=http://hi.csdn.net/attachment/201202/28/8774046_1330418308P4W5.jpg][/img]
expected primary-expression before ']' token 这是什么错误
G:\C++初级\string2.cpp In constructor `String::String()': rn54 G:\C++初级\string2.cpp expected primary-expression before ']' token rnrn以上就是错误的提示,知道的请告知下,谢谢rnrn#includern#includernusing namespace std;rnrnclass Stringrnrnprivate:rn char *ptr;rnpublic:rn String();rn String(char *s);rn String(const String &src);rn ~String();rnrn String& operator = (const String &src)rn rn cpy(src.ptr); return *this;rn rnrn String& operator = (char *s)rn rn cpy(s); return *this;rn rnrn String operator + (char *s);rnrn int operator == (const String &other);rn operator char*() return ptr;rnrn void cat(char *s);rn void cpy(char *s);rn rn;rnrn int main()rn rn String a,b,c;rn a = "I";rn b = "am";rn c = "so";rn String d = a + b + c + "very happpy!\n";rn cout<
请教:为什么出现 expected primary-expression before '' token
为什么出现 expected primary-expression before '' tokenrn 悬赏分:30 - 离问题结束还有 14 天 23 小时 rn/*4.已知顺序表L递增有序,编写一个算法,将X插入到先心病的适当位置上,以保持线性表的有序性。*/rn#define OK 1rn#define ERROR 0rn#define MAXSIZE 100rn#includern#includernrntypedef structrnint elem[MAXSIZE];rn int last;rnSeqList;rnrnint InsList(SeqList *L,int e)rnif(L->last==MAXSIZE-1)rn printf("表已满,无法插入\n");rn return(ERROR);rn int k;rn for(k=L->last++;eelem[k];k--)rn L->elem[k+1]=L->elem[k];rn L->elem[k+1]=e;rn return(OK);rnrnrnint main()rnint i;rn SeqList L;rn L.elem[MAXSIZE]=1,3,6,7,9,12,34,45,46,67;rn L.last=9;rn printf("数据插入前:");rn for(i=0;i
求助expected primary-expression before '=' token 如何解决
哪位高手帮忙看下哪里出问题了.rn代码如下:rnrn#includernusing namespace std;rn#define Pi=3.1415926rnclass CIRCLErn private:rn float mfR;rn public:rn CIRCLE(float fR);rn void OutputArea();rn void OutputCircum();rn ;rnint main()rnrn CIRCLE a(1.23),b(5.67);rn a.OutputArea();rn a.OutputCircum();rn b.OutputArea();rn b.OutputCircum();rn system("pause");rn return 0;rnrnCIRCLE::CIRCLE(float fR)rnrn mfR=fR;rnrnvoid CIRCLE::OutputArea()rnrn cout<<"The area is :"<
相关热词 c# login 居中 c# 考试软件 c# 自然语言分析 c# 分段读取文件 c# 泛型反射 c#打断点 c# 时间转多少秒 c# 线程函数加参数 c# modbus 读取 c#查询集合表