vc6的编译是不是存在问题?怎么老出莫名奇妙的问题?

success_victory 2004-04-08 04:00:14
compile通过,但excute是出现错误,这两个之间有什么区别?
出现错误提示是什么愿因?
f:\sourcecode\c++\datastructure\chapter3\linklist.cpp(63) : error C2440: '=' : cannot convert from 'class LinkNode<int> *(__thiscall LinkNode<int>::*)(void)' to 'class LinkNode<int> *'
There is no context in which this conversion is possible
d:\program files\microsoft visual studio\vc98\include\xmemory(59) : while compiling class-template member function 'void __thiscall


有没有vc6.0针对编译的入门书籍?
vc6的补丁在哪儿可下载?
...全文
118 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
success_victory 2004-04-08
  • 打赏
  • 举报
回复
提示上面的while中的语句error,
while ((p != 0) && (k < index -1))
{
p = p->NextNode; --这一句提示错误的,但编译通过
k ++;
}
success_victory 2004-04-08
  • 打赏
  • 举报
回复
// LinkList.cpp: implementation of the LinkList class.
//
//////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
#include "..\stdafx.h"
#include "LinkList.h"


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
template <typename elemType>
LinkList<elemType>::LinkList():first(0)
{

}
template <typename elemType>
LinkList<elemType>::~LinkList()
{

}

template <typename elemType>
void LinkList<elemType>::Insert(const elemType &elem,const int &index)
{
LinkNode<elemType> *p = first; int k = 0;
while ((p != 0) && (k < index -1))
{
p = p->NextNode;
k ++;
}

if ((p == 0) && (first != 0))
{
cout << ("out range of array") << endl;
//return 0;
}
/*
LinkNode<elemType> *newNode = new LinkNode<elemType>(elem);
if ((first == 0) || (index == 0))
{
newNode->NextNode = first;
first = newNode
}
else
{
newNode->NextNode = p->NextNode;
p->NextNode = newNode;
}
*/
}

template <typename elemType>
LinkNode<elemType> *LinkList<elemType>::Find(elemType &elem)
{
LinkNode *temp = first->NextNode;
while (temp != 0)
{
if (elemType == temp.data)
{
break;
}
temp = temp->NextNode;
}

return temp;

}

template <typename elemType>
void LinkList<elemType>::Delete(const int &index)
{
return;
}
success_victory 2004-04-08
  • 打赏
  • 举报
回复
的确编译过了,代码如下(单向链表):
// LinkList.h: interface for the LinkList class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_LINKLIST_H__A9A55711_40F0_47B0_9B15_EACDB6F9AC7A__INCLUDED_)
#define AFX_LINKLIST_H__A9A55711_40F0_47B0_9B15_EACDB6F9AC7A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "..\stdafx.h"

template <typename elemType> class LinkList;

template <typename elemType> class LinkNode
{
friend class LinkList<elemType>;
public:
LinkNode(const elemType elem):data(elem),nextNode(0) {};
LinkNode(const LinkNode *n):data(n->data),nextNode(0){};
virtual ~LinkNode();
inline LinkNode<elemType> *NextNode() {return nextNode;}
inline elemType &GetData() {return data;}
private:
elemType data;
LinkNode<elemType> *nextNode;
};

template <typename elemType> class LinkList
{
public:
LinkList();
virtual ~LinkList();

void Insert(const elemType &,const int &);
LinkNode<elemType> *GetFirst() {return first;}
LinkNode<elemType> *Find(elemType &);
void Delete(const int &i);
int Length() {return length;}

private:
int length;
LinkNode<elemType> *first;
};



#endif // !defined(AFX_LINKLIST_H__A9A55711_40F0_47B0_9B15_EACDB6F9AC7A__INCLUDED_)

itmaster 2004-04-08
  • 打赏
  • 举报
回复
根本就编译没过啊
ahao 2004-04-08
  • 打赏
  • 举报
回复
你这个叫compile通过?
suigui 2004-04-08
  • 打赏
  • 举报
回复
cannot convert from 'class LinkNode<int> *(__thiscall LinkNode<int>::*)(void)' to 'class LinkNode<int> *'
class LinkNode<int> *(__thiscall LinkNode<int>::*)(void)
是一个函数指针
class LinkNode<int> *显然不是,两者不能转换。
再仔细查查代码吧。
vollin 2004-04-08
  • 打赏
  • 举报
回复
出了错,你可以选中错误号然后按F1,就会了解到出错的具体情况。当然你必须要安了MSDN,没有MSDN想用好VC是不可能的。
ymbymb 2004-04-08
  • 打赏
  • 举报
回复
还是要学会从MSDN中找到解决问题的方法
success_victory 2004-04-08
  • 打赏
  • 举报
回复
还有没有好的建议?
success_victory 2004-04-08
  • 打赏
  • 举报
回复
多谢hhdlotus(荷花淀) !
success_victory 2004-04-08
  • 打赏
  • 举报
回复
初用vc,老感觉vc6编译老出问题,本来没问题的程序,稍微改了一点,结果出来一大堆的error,这是不是vc6的一贯的作风?
楼上四座山峰的老大,能不能帮个忙,解释一下原因?给个链接也可。
hhdlotus 2004-04-08
  • 打赏
  • 举报
回复
compile通过说明你的程序语法没有错误,execute出错是在内存中运行时出错,归根到底应该是你的程序有问题,当然也有系统出错的可能。
《C++程序调试》一书应该可以让你入门,里面用的是Visual C++ 6.0
CCsdnCC 2004-04-08
  • 打赏
  • 举报
回复
"有没有vc6.0针对编译的入门书籍?" v.s. "vc6的编译是不是存在问题?怎么老出莫名奇妙的问题?"


你提的问题好大!!!

16,548

社区成员

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

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

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