本文介绍了声明语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试图编写一个关于卡车库存的程序,卡车来来往往以及每个卡车的数量,但不断提出声明语法错误..任何帮助将不胜感激。我使用Borland C ++。谢谢Im trying to write a program about a truck inventory with trucks coming and going and the amount in each one, but keep coming up with declaration syntax error.. Any help would be greatly appreciated. Im using Borland C++. Thanks 展开 | 选择 | Wrap | 行号推荐答案如果你愿意,它会对我们有很大的帮助发布你得到的确切错误,并说明它们发布的列表的哪些行。It would greatly help us if you would post the exact errors you are getting and indicate on what lines of the posted listing they occur.但是我注意到 第10/19行:构造函数名称与类名不匹配 第29行:赎回代码实际上不在函数中 第10/39行声明/定义类名称不匹配 第48行:主要返回int NOT void,not {表示主要功能的开始。 第50,51,56行:随机符号在其他地方没有定义 Line 60:随机数组语法没有附加到任何符号名称 风格点数 类TRUCK(S)这是不寻常的造型,但不是严格错误,因为类名全部是大写字母,类似地,所有成员名称都是大写字母也是不寻常的样式。在我的公司里,所有大写字母都保留用于consts和static consts。 第119行:创建TRUCK的工厂函数可能并且可能会更好地成为类的静态成员函数TRUCK 第139行:这样输出TRUCK的功能最好不要成为TRUCK的成员,但是一个替代方案是制作一个处理卡车类型的iostream辅助功能允许 cout<< truck;However I notice thatLine 10/19: constructor name does not match class nameLine 29: Ransom code not actually in a functionLine 10/39 Declaration/definition class name mismatchLine 48: main returns int NOT void, not { indicating the start of the main function.Line 50, 51, 56: Random symbols not defined anywhere elseLine 60: random array syntax not attached to any symbol namePoints on styleclass TRUCK(S) it is unusual styling, though not strictly wrong, for a class name to be all in capital letters and similarly it is also unusual styling for all member names to be in capitals. In my company all caps is reserved for consts and static consts.Line 119: The factory function to create a TRUCK could be and probably would be better being a static member function of the class TRUCKLine 139: a function like this to output a TRUCK would be better off being a member of TRUCK, however an alternitive would be to make an iostream helper function that handles the truck type allowingcout << truck;此外,范围解析中的::(两个冒号),如Classname :: Functionname()....它们之间不应有空格。Also, :: (two colons) in scope resolution, like Classname::Functionname().... should not have space between them. 这篇关于声明语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 05-27 22:33