SOS VC编绎时错误不解!! T_T

xteeq 2005-03-31 09:53:01
小弟刚学类
学着做了一个栈的类
是这样做的
新建一个工程:
stack_.h //栈类的文件
sNode.h //栈的结点类文件
---------------------------------------
stack.cpp //栈的mian()函数在这里面
stack_.cpp //栈类的成员函数地这里面
sNode.cpp //栈的结点类成员函数在这里面

可是我怎么一编绎 sNode.cpp 就出错了:

sNode.h:
/////////////////////////////////////////////////
#ifndef sNode_
#define sNode_

class sNode
{
public:
sNode(){}

sNode(int itemp=0)
{Value=itemp;Prior=Next=NULL;}

sNode(int itemp,sNode *ptemp);

private:
int Value;
sNode *Prior, *Next;
};

#endif //sNode_
//////////////////////////////////////////////////////////
sNode.cpp:

#include "Node.h"

sNode::sNode(int itemp,sNode *ptemp)
{
Value=itemp;
Prior=NULL;
Next=ptemp;
ptemp->Prior=this;
}

//////////////////////////////////////////////////////////
stack.cpp:

#include <iostream>
using namespace std;

int main()
{
cout<<"Hellow ! World!"<<endl;
}
/////////////////////////////////////////////////////////

编绎sNode.cpp
时出错:
d:\mypro\vc\stack_1\node.h(22) : warning C4520: 'sNode' : multiple default constructors specified
d:\mypro\vc\stack_1\node.h(14) : error C2065: 'NULL' : undeclared identifier
d:\mypro\vc\stack_1\node.h(14) : error C2440: '=' : cannot convert from 'int' to 'class sNode *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
d:\mypro\vc\stack_1\node.cpp(12) : error C2440: '=' : cannot convert from 'int' to 'class sNode *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

各位高手帮帮忙,看看是什么地方出错了.还有我刚学C++各位大虾有什么经验和推荐的书么!
谢谢了!
...全文
66 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xteeq 2005-03-31
  • 打赏
  • 举报
回复
好了,我明白了,发现了一点错误,呵呵
谢谢你了!!!对了我刚学C++,能认识你么
QQ:105673546
我加你也可以,可以留个QQ么
xteeq 2005-03-31
  • 打赏
  • 举报
回复
改了可是还有三个错误,少了一个. T_T

d:\mypro\vc\stack_1\node.h(14) : error C2065: 'NULL' : undeclared identifier
d:\mypro\vc\stack_1\node.h(14) : error C2440: '=' : cannot convert from 'int' to 'class sNode *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
d:\mypro\vc\stack_1\node.cpp(12) : error C2440: '=' : cannot convert from 'int' to 'class sNode *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
UniverseWisdom 2005-03-31
  • 打赏
  • 举报
回复
默认参数的函数与函数重载不能同时使用,不然会发生歧义。
例如,写sNode p = new sNode;
系统是看做sNode()
还是sNode(int itemp=0)
呢?
xteeq 2005-03-31
  • 打赏
  • 举报
回复
就是sNode.h我刚复制的时候复制了先前那个文件里的Node.cpp那里面用的是Node.h
UniverseWisdom 2005-03-31
  • 打赏
  • 举报
回复
sNode.cpp中
#include "Node.h"
是什么?

16,470

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧