C++编译一直出现这样的错误,error C2039: 'setNo' : is not a member of 'Rectangle<ElemType>'

代码如下:template<typenameElemType>classRectangle{public:classRectangleNo{public:intno;};... 代码如下:
template<typename ElemType>
class Rectangle
{
public:
class RectangleNo
{
public:
int no;
};

Rectangle();
Rectangle(const Rectangle &otherD);
virtual ~Rectangle();
void setNO(int i);
protected:
ElemType length;
ElemType width;
RectangleNo myNo;

};

template <typename ElemType>
Rectangle<ElemType>::Rectangle()
{
length=width=0;
cout<<" 自动调用构造函数"<<endl;
}

template <typename ElemType>
Rectangle<ElemType>::Rectangle(const Rectangle<ElemType>& otherD)
{
length=otherD.length;
width=otherD.width;
myNo=otherD.myNo;
cout<<" 自动调用拷贝初始化构造函数初始化为("length<<","<<width<<")"<<endl;
}

template<typename ElemType>
Rectangle<ElemType>::~Rectangle()
{
cout<<"\n 第"<<myNo.no<<"个长方形对象("<<length<<","<<width<<")生存期结束!"<<endl;
}

template <typename ElemType>
void Rectangle<ElemType>::setNo(int i)
{
myNo.no=i;
}

他说setNo不是Retangle的成员。可是我set明明就声明在这个类里面的啊!求大神解答。多谢。因为没有多少财富值了,不够悬赏10了,只能悬赏5,求大神解答
展开
 我来答
汽车安全出行
2014-04-22 · TA获得超过490个赞
知道小有建树答主
回答量:416
采纳率:66%
帮助的人:303万
展开全部
void Rectangle<ElemType>::setNO(int i)
{
myNo.no=i;
}
应该是你最后那域运算符没注意“::”
我在我这里重写了::通过了编译
百度网友dfbd5e4
2022-03-23
知道答主
回答量:8
采纳率:0%
帮助的人:1.8万
展开全部
定义的setNO,O是大写,结果使用的时候用的setNo,将o小写了,仅此而已。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式