函数调用缺少参数列表 [英] Function call missing argument list

查看:178
本文介绍了函数调用缺少参数列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个班级:

点继承自Shape,Circle来自Point和Cylinder来自Circle。

point,circle,cylinder是Point,Circle,Cylinder的对象。

I have 4 classes:
Point inherits from Shape,Circle from Point and Cylinder from Circle.
point, circle, cylinder are objects to Point, Circle, Cylinder.

Shape *shapeVector[3];
shapeVector[0]=&point;
shapeVector[1] = &circle;
shapeVector[2] = &cylinder;





当我这样做时:



When I do this:

Shape *baseClassPtr=shapeVector[ 1 ];
baseClassPtr->GetName();



它正在工作。但是当我这样做时:


It is working.But when I do this:

virtualViaPointer( shapeVector[ i ] ); // for all i(0,1,2)

   void virtualViaPointer(  Shape *baseClassPtr )    
   {                         	   
	   cout << baseClassPtr->GetName() << ": " ; 
   }



我收到此错误:


I''m getting this error:

Error   2   error LNK1120: 1 unresolved externals 
Error	1	error LNK2019: unresolved external symbol "void __cdecl virtualViaPointer(class Shape const *)" (?virtualViaPointer@@YAXPBVShape@@@Z) referenced in function _wmain

推荐答案

除非我遗漏了某些内容,否则您只需要添加括号:

Unless I am missing something, it looks like you simply have to add the parenthesis:
cout << baseClassPtr->GetName() << ": " ;





你实际上没有显示GetName()声明,但对我来说这看起来好像会解决它。



Soren Madsen



You did not actually show the GetName() declaration, but to me this looks like it would fix it.

Soren Madsen


这篇关于函数调用缺少参数列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆