collect2:Ld返回1退出状态build make错误 [英] collect2: Ld returned 1 exit status build make error

查看:3747
本文介绍了collect2:Ld返回1退出状态build make错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译器:Qt
语言:C ++



这个程序不是为我哈哈,这是我第三次要求帮助,并且它驱使我疯狂(感谢大家对我这么耐心和帮助我)



我试过运行我的程序(第100次再次)因为我可以' t得到ostream排序,我注释掉所有的cout函数在我的主要所以我可以处理我的代码的其余部分。



我切换到Compile Output ...和gosh ..

p>


为项目运行构建步骤List ...
配置不变,跳过qmake步骤。
开始:C:/Qt/2010.05/mingw/bin/mingw32-make.exe-w
mingw32-make:输入目录`C:/Qt/2010.05/bin/List-build-桌面'



C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug



mingw32-make [1]:输入目录
`C:/Qt/2010.05/bin/List-build-desktop'



g ++ -enable-stdcall -fixup -Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\List.exe debug / main.o debug / list.o -Lc:\Qt\2010.05\qt\lib-lQtCored4

debug / main.o:C:\ Qt \2010.05\bin\List-build-desktop /../ List // List.h:194:
未定义引用`List :: getNewNode(double const&)'



debug / main.o:C:\Qt\2010.05\bin\List-build-desktop /../ List // List.h:215:
未定义引用`List :: getNewNode(double const&)'



debug / main.o:C:\Qt\2010.05\bin\List -build-desktop /../ List // List.h:215:
未定义引用`List :: getNewNode(int const&)'



debug / main.o:C:\Qt\2010.05\bin\List-build-desktop /../ List // List.h:194:
未定义引用`List :: getNewNode int const&)'

debug / main.o:C:\ Qt \2010.05\bin/\\List-build- /List.h:466:
未定义引用`List :: getNewNode(int const&)'

debug / main.o:C:\ Qt \2010.05\bin\List-build-desktop /../ List // List.h:466:
未定义引用`List :: getNewNode(double const&)'



collect2:ld退回1退出状态



mingw32-make [1]:离开目录
`C:/ Qt /2010.05/bin/List-build-desktop'



mingw32-make:离开目录`C:/Qt/2010.05/bin/List-build-desktop' p>

mingw32-make [1]: * [debug\List.exe]错误1



mingw32-make: * [debug]错误2



程序C:/Qt/2010.05/mingw/bin/mingw32 -make.exe从
代码%2退出。构建项目时出错List(target:Desktop)当
执行构建步骤'Make'


我有2个头文件和一个源文件。
标题:ListNode.h和list.h和我的cpp是main.cpp



一切都相互链接,所以我不明白为什么它给我未定义的参考错误。



我的所有其他朋友都已经放弃了这项任务,我拒绝放弃。我今晚不会去睡觉哈哈。再次感谢您的帮助!



EDIT :: - CODE



ListNode.h

  #ifndef LISTNODE_H 
#define LISTNODE_H

template< typename NODETYPE>类List;

template< typename NODETYPE>
class ListNode
{
friend class List< NODETYPE> ;;

public:
ListNode(const NODETYPE&);
NODETYPE getData()const;
private:
NODETYPE data;
ListNode< NODETYPE> * nextPtr;

};

template< typename NODETYPE>
ListNode< NODETYPE> :: ListNode(const NODETYPE& info)
:data(info),nextPtr(0)
{

}

template< ; typename NODETYPE>
NODETYPEListNode< NODETYPE> :: getData()const
{
return data;
}


#endif // LISTNODE_H

我不会把一切,因为它是很多...这是List.h..I只能想象它有多少仍然是错误,但我不能检查,因为错误...

  #include< iostream> 
using std :: cout;

#include< fstream>

#include< string>
using std :: ostream;

#includeListNode.h

template<类型名NODETYPE>
class List
{
// template< typename OUTPUT>
// friend ostream& operator<<(ostream& const List< NODETYPE&);

public:
List();
〜List();
void insertAtFront(const NODETYPE&);
void insertAtBack(const NODETYPE&);
bool removeFromFront(NODETYPE&);
bool removeFromBack(NODETYPE&);
bool isEmpty()const;
void print()const;


bool append(const NODETYPE&);
bool add_n(int,const NODETYPE&);
bool concat(List&);
void reverse();
bool remove_last();
bool remove_n(int);
void sort();
bool merge(List&);
void add_in(const NODETYPE&);
void remove(const NODETYPE&);
NODETYPE sum();
int count();

private:
ListNode< NODETYPE> * firstPtr;
ListNode< NODETYPE> * lastPtr;

ListNode< NODETYPE> * getNewNode(const NODETYPE&);

};

template< typename NODETYPE>
List< NODETYPE> :: List()
:firstPtr(0),lastPtr(0)
{

}

template< ;类型名NODETYPE>
List< NODETYPE> ::〜List()
{
if(!isEmpty())
{
cout< Destroying Nodes ... \\\
;

ListNode< NODETYPE> * currentPtr = firstPtr;
ListNode< NODETYPE> * tempPtr;

while(currentPtr!= 0)
{
tempPtr = currentPtr;
cout< tempPtr-> data<< \\\
;
currentPtr = currentPtr-> nextPtr;
delete tempPtr;
}
}

cout< 所有节点销毁\\\
\\\
;
}

template<类型名NODETYPE>
void List< NODETYPE> :: insertAtFront(const NODETYPE& value)
{
ListNode< NODETYPE> * newPtr = getNewNode(value);

if(isEmpty())
firstPtr = lastPtr = newPtr;
else
{
newPtr-> nextPtr = firstPtr;
firstPtr = newPtr;
}
}

template<类型名NODETYPE>
void List< NODETYPE> :: insertAtBack(const NODETYPE& value)
{
ListNode< NODETYPE> * newPtr = getNewNode(value);

if(isEmpty())
firstPtr = lastPtr = newPtr;
else
{
lastPtr->下一个Ptr = newPtr;
lastPtr = newPtr;
}
}

template<类型名NODETYPE>
bool List< NODETYPE> :: removeFromFront(NODETYPE& value)
{
if(isEmpty())
return false;
else
{
ListNode< NODETYPE> * tempPtr = firstPtr;

if(firstPtr == lastPtr)
firstPtr = lastPtr = 0;
else
firstPtr = firstPtr-> nextPtr;

value = tempPtr-> data;
delete tempPtr;
return true;
}
}

模板< typename NODETYPE>
bool List< NODETYPE> :: removeFromBack(NODETYPE& value)
{
if(isEmpty())
return false;
else
{
ListNode< NODETYPE> * tempPtr = lastPtr;

if(firstPtr == lastPtr)
firstPtr = lastPtr = 0;
else
{
ListNode< NODETYPE> * currentPtr = firstPtr;

while(currentPtr-> nextPtr!= lastPtr)
currentPtr = currentPtr-> nextPtr;

lastPtr = currentPtr;
currentPtr-> nextPtr = 0;
}
value = tempPtr-> data;
delete tempPtr;
return true;
}
}

模板< typename NODETYPE>
bool List< NODETYPE> :: isEmpty()const
{
return firstPtr == 0;
}

template< typename NODETYPE>
void List< NODETYPE> :: print()const
{
if(isEmpty())
{
cout< n \\\
;
return;
}
ListNode< NODETYPE> * currentPtr = firstPtr;

cout<< 名单是:;

while(currentPtr!= 0)
{
cout<< currentPtr-> data> '';
currentPtr = currentPtr-> nextPtr;
}

cout<< \\\
\\\
;
}

/ * template< typename NODETYPE>
ostream& operator<<(ostream& output,const List< NODETYPE&& value)
{
output<值;
return output;
} * /


模板< typename NODETYPE>
bool List< NODETYPE> :: append(const NODETYPE& value)
{
ListNode< NODETYPE& * newPtr = getNewNode(value);

if(isEmpty())
{
firstPtr = lastPtr = newPtr;
return true;
}
else
{
ListNode< NODETYPE> * tempPtr = lastPtr;

tempPtr-> nextPtr = newPtr;
lastPtr = newPtr;
return true;
}

}

模板< typename NODETYPE>
bool List< NODETYPE> :: add_n(int a,const NODETYPE& value)
{
ListNode< NODETYPE& * newPtr = getNewNode(value);

if(isEmpty())
{
firstPtr = lastPtr = newPtr;
return true;
}
if(a <= count())
{
lastPtr-> nextPtr = newPtr;
lastPtr = newPtr;
return true;
}
else
{
ListNode< NODETYPE> * currentPtr = firstPtr;
for(int cntr = 1; cntr< count(); cntr ++)
{
if(cntr == a)
{
newPtr-> nextPtr = currentPtr-> nextPtr;
currentPtr-> nextPtr = newPtr;
return true;
}

currentPtr = currentPtr-> nextPtr;
}
return false;
}
}

模板< typename NODETYPE>
bool List< NODETYPE> :: concat(List< NODETYPE>& li)
{
if(isEmpty())
return false;
if(li.isEmpty())
return false;
else
{
ListNode< NODETYPE> * tempPtr = lastPtr;

tempPtr-> nextPtr = li.firstPtr;
tempPtr = tempPtr-> nextPtr;

while(tempPtr-> nextPtr!= 0)
tempPtr = tempPtr-> nextPtr;

lastPtr = tempPtr;

return true;

}

}

模板< typename NODETYPE>
void List< NODETYPE> :: reverse()
{
if(isEmpty())
return;
else
{
int chk = count();
ListNode< NODETYPE> * currentPtr = firstPtr-> nextPtr;
ListNode< NODETYPE> * tempPtr = firstPtr;
ListNode< NODETYPE> * tempPtr2;

for(int a = 1; a< chk; a ++)
{
tempPtr2 = currentPtr-> nextPtr;
tempPtr-> nextPtr = currentPtr-> nextPtr;
currentPtr-> nextPtr = firstPtr;
firstPtr = currentPtr;
currentPtr = tempPtr2;

}

lastPtr = tempPtr;
}
}

main.cpp

  #includeList.h

#include< iostream>
using std :: cout;
using std :: endl;


int main()
{
List< int> Li,Li2,Li3;
List< double> Ld,Ld2;

Ld.append(11.1);
Ld.append(22.2);
Ld.append(33.3);
Ld.add_n(35.5,2);
// cout<< Ld是:< Ld < endl;

Ld.reverse();
// cout<< Ld是:< Ld < endl;

Li.add_n(15,-1);
Li.add_n(16,0);
Li.add_n(17,1);
Li.append(10);
// cout<< Li is:< Li < endl;

Li2.append(5);
Li2.append(6);
Li2.add_n(7,2);
Li2.add_n(8,1);
// cout<< Li 2是:< Li2< endl;

//在连接之后不应该使用Li2,因为
//元素不会被复制,只是连接形成一个列表。

Li.concat(Li2);
// cout<< Li is:< Li < endl;
// cout<< Li 2是:< Li2< endl;

Li.sort();
// cout<< Li is:< Li < endl;

Li3.append(20);
Li3.append(10);
Li3.add_n(50,1);
Li3.add_n(40,3);
// cout<< Li 3是:< Li 3< endl;

Li.merge(Li3);
// cout<< Li is:< Li < endl;
// cout<< Li 3是:< Li 3< endl;

Li3.sort();
// cout<< Li 3是:< Li 3< endl;

//合并后不应使用Li3,因为节点已被删除。

Li.merge(Li3);
// cout<< Li is:< Li < endl;

Li.add_in(25);
Li.add_in(4);
// cout<< Li is:< Li < endl;

Li.remove(10);
Li.remove(50);
// cout<< Li is:< Li < endl;

Ld.add_in(14.3);
Ld.remove(14.3);
// cout<< Ld是:< Ld < endl;

Ld2 = Ld;
// cout<< Ld是:< Ld < endl;
// cout<< Ld2是:< Ld2 < endl;

Ld.sort();
// cout<< Ld是:< Ld < endl;
// cout<< Ld2是:< Ld2 < endl;

cout<< Li具有< Li.count()< 总价值为
< Li.sum() endl;

cout<< Ld has<< Ld.count()< 总价值为
< Ld.sum()<< endl;


return 0;
}



根据要求

.pro文件


$ b b

 #------------------------------------ ------------- 

#QtCreator创建的项目2012-09-20T02:33:43

#---- ---------------------------------------------

QT + = core

QT - = gui

TARGET = List
CONFIG + = console
CONFIG - = app_bundle

TEMPLATE = app


SOURCES + = main.cpp \
list.cpp

HEADERS + = \
list.h \
ListNode.h


解决方案

您似乎忘记创建 List :: getNewNode 函数。


Compiler: Qt Language: C++

This program is just not for me haha, this is the third time I've had to ask for help, and it's driving me crazy (thank you everyone for being so patient and helpful with me)

I tried running my program (again for the millionth time) Since I can't get the ostream sorted out, I commented out all the cout functions in my main so I could deal with the rest of my code. But when I try to run it I get collect2: ld returned 1 exit status in my build issues.

I switched to Compile Output... and gosh..

Running build steps for project List... Configuration unchanged, skipping qmake step. Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w mingw32-make: Entering directory `C:/Qt/2010.05/bin/List-build-desktop'

C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug

mingw32-make[1]: Entering directory `C:/Qt/2010.05/bin/List-build-desktop'

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\List.exe debug/main.o debug/list.o -L"c:\Qt\2010.05\qt\lib" -lQtCored4

debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:194: undefined reference to `List::getNewNode(double const&)'

debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:215: undefined reference to `List::getNewNode(double const&)'

debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:215: undefined reference to `List::getNewNode(int const&)'

debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:194: undefined reference to `List::getNewNode(int const&)'

debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:466: undefined reference to `List::getNewNode(int const&)'

debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:466: undefined reference to `List::getNewNode(double const&)'

collect2: ld returned 1 exit status

mingw32-make[1]: Leaving directory `C:/Qt/2010.05/bin/List-build-desktop'

mingw32-make: Leaving directory `C:/Qt/2010.05/bin/List-build-desktop'

mingw32-make[1]: * [debug\List.exe] Error 1

mingw32-make: * [debug] Error 2

The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2. Error while building project List (target: Desktop) When executing build step 'Make'

That's basically what I got. I have 2 header files and one source file. Headers: ListNode.h and list.h and my cpp is main.cpp

everything links to each other, so i don't understand why it's giving me undefined reference errors.

All my other friends have pretty much given up on this assignment, and I refuse to give up. I just won't go to bed tonight ha. Thanks again for the help!

EDIT::-- CODE

ListNode.h

#ifndef LISTNODE_H
#define LISTNODE_H

template<typename NODETYPE> class List;

template<typename NODETYPE>
class ListNode
{
    friend class List< NODETYPE >;

public:
    ListNode(const NODETYPE &);
    NODETYPE getData() const;
private:
    NODETYPE data;
    ListNode< NODETYPE > *nextPtr;

};

template<typename NODETYPE>
ListNode< NODETYPE >::ListNode(const NODETYPE &info)
    :data(info), nextPtr(0)
{

}

template<typename NODETYPE>
NODETYPE ListNode< NODETYPE >::getData() const
{
    return data;
}


#endif // LISTNODE_H

I won't put everything, because it's a lot... this is the List.h..I can only imagine how much of it is still wrong, but I can't check because the error...

#include <iostream>
using std::cout;

#include <fstream>

#include <string>
using std::ostream;

#include "ListNode.h"

template< typename NODETYPE >
class List
{
  //template <typename OUTPUT >
  //friend ostream &operator <<(ostream &, const List<NODETYPE> & );

public:
    List();
    ~List();
    void insertAtFront( const NODETYPE & );
    void insertAtBack( const NODETYPE & );
    bool removeFromFront( NODETYPE & );
    bool removeFromBack( NODETYPE & );
    bool isEmpty() const;
    void print() const;


    bool append(const NODETYPE &);
    bool add_n(int, const NODETYPE &);
    bool concat(List&);
    void reverse();
    bool remove_last();
    bool remove_n(int);
    void sort();
    bool merge(List&);
    void add_in(const NODETYPE &);
    void remove(const NODETYPE &);
    NODETYPE sum();
    int count();

private:
    ListNode< NODETYPE > *firstPtr;
    ListNode< NODETYPE > *lastPtr;

    ListNode< NODETYPE > *getNewNode( const NODETYPE &);

};

template<typename NODETYPE>
List<NODETYPE>::List()
    : firstPtr(0), lastPtr(0)
{

}

template< typename NODETYPE>
List<NODETYPE>::~List()
{
    if( !isEmpty() )
    {
        cout << "Destroying Nodes...\n";

        ListNode< NODETYPE > *currentPtr = firstPtr;
        ListNode< NODETYPE > *tempPtr;

        while ( currentPtr != 0)
        {
            tempPtr = currentPtr;
            cout << tempPtr->data << "\n";
            currentPtr = currentPtr->nextPtr;
            delete tempPtr;
        }
    }

    cout << "All nodes destroyed \n\n";
}

template< typename NODETYPE >
void List< NODETYPE>::insertAtFront(const NODETYPE &value)
{
    ListNode< NODETYPE > *newPtr = getNewNode (value);

    if( isEmpty())
        firstPtr = lastPtr = newPtr;
    else
    {
        newPtr->nextPtr = firstPtr;
        firstPtr = newPtr;
    }
}

template< typename NODETYPE >
void List<NODETYPE>::insertAtBack(const NODETYPE &value)
{
    ListNode<NODETYPE> *newPtr = getNewNode(value);

    if( isEmpty())
        firstPtr = lastPtr = newPtr;
    else
    {
        lastPtr->nextPtr = newPtr;
        lastPtr = newPtr;
    }
}

template< typename NODETYPE >
bool List<NODETYPE>::removeFromFront(NODETYPE &value)
{
    if(isEmpty())
        return false;
    else
    {
        ListNode<NODETYPE> *tempPtr = firstPtr;

        if(firstPtr == lastPtr)
            firstPtr = lastPtr = 0;
        else
            firstPtr = firstPtr->nextPtr;

        value = tempPtr->data;
        delete tempPtr;
        return true;
    }
}

template<typename NODETYPE>
bool List<NODETYPE>::removeFromBack(NODETYPE &value)
{
    if( isEmpty())
        return false;
    else
    {
        ListNode<NODETYPE> *tempPtr = lastPtr;

        if(firstPtr == lastPtr)
            firstPtr = lastPtr = 0;
        else
        {
            ListNode<NODETYPE> *currentPtr = firstPtr;

            while (currentPtr->nextPtr != lastPtr)
                currentPtr = currentPtr->nextPtr;

            lastPtr=currentPtr;
            currentPtr->nextPtr = 0;
        }
        value = tempPtr->data;
        delete tempPtr;
        return true;
    }
}

template<typename NODETYPE>
bool List<NODETYPE>::isEmpty() const
{
    return firstPtr == 0;
}

template<typename NODETYPE>
void List<NODETYPE>::print() const
{
    if( isEmpty())
    {
        cout<<"The list is empty \n\n";
        return;
    }
    ListNode<NODETYPE> *currentPtr = firstPtr;

    cout<< "The list is: ";

    while(currentPtr != 0)
    {
        cout<<currentPtr->data>> ' ';
        currentPtr = currentPtr->nextPtr;
    }

    cout<< "\n\n";
}

/*template<typename NODETYPE>
ostream &operator <<(ostream &output, const List<NODETYPE>& value)
{
    output << value;
    return output;
}*/


template<typename NODETYPE>
bool List<NODETYPE>::append(const NODETYPE &value)
{
    ListNode<NODETYPE> *newPtr = getNewNode(value);

   if(isEmpty())
   {
        firstPtr = lastPtr = newPtr;
        return true;
    }
    else
    {
        ListNode<NODETYPE> *tempPtr = lastPtr;

        tempPtr->nextPtr=newPtr;
        lastPtr = newPtr;
        return true;
    }

}

template<typename NODETYPE>
bool List<NODETYPE>::add_n(int a, const NODETYPE &value)
{
    ListNode<NODETYPE> *newPtr = getNewNode(value);

    if(isEmpty())
    {
        firstPtr = lastPtr = newPtr;
        return true;
    }
    if(a <= count())
    {
        lastPtr->nextPtr = newPtr;
        lastPtr = newPtr;
        return true;
    }
    else
    {
        ListNode<NODETYPE> *currentPtr = firstPtr;
        for(int cntr = 1; cntr < count(); cntr++)
        {
            if(cntr == a)
            {
                newPtr->nextPtr = currentPtr->nextPtr;
                currentPtr->nextPtr = newPtr;
                return true;
            }

            currentPtr = currentPtr->nextPtr;
        }
        return false;
    }
}

template<typename NODETYPE>
bool List<NODETYPE>::concat(List<NODETYPE> &li)
{
    if(isEmpty())
        return false;
    if(li.isEmpty())
        return false;
    else
    {
        ListNode<NODETYPE> *tempPtr = lastPtr;

        tempPtr->nextPtr = li.firstPtr;
        tempPtr = tempPtr->nextPtr;

        while(tempPtr->nextPtr != 0)
            tempPtr = tempPtr->nextPtr;

        lastPtr = tempPtr;

        return true;

    }

}

template<typename NODETYPE>
void List<NODETYPE>::reverse()
{
    if(isEmpty())
        return;
    else
    {
       int chk = count();
       ListNode<NODETYPE> *currentPtr = firstPtr->nextPtr;
       ListNode<NODETYPE> *tempPtr = firstPtr;
       ListNode<NODETYPE> *tempPtr2;

       for(int a = 1; a < chk; a++)
       {
           tempPtr2 = currentPtr->nextPtr;
           tempPtr->nextPtr = currentPtr->nextPtr;
           currentPtr->nextPtr = firstPtr;
           firstPtr = currentPtr;
           currentPtr = tempPtr2;

       }

       lastPtr = tempPtr;
    }
}

main.cpp

#include "List.h"

#include <iostream>
using std::cout;
using std::endl;


int main()
{
  List<int> Li, Li2, Li3;
  List<double> Ld, Ld2;

  Ld.append(11.1);
  Ld.append(22.2);
  Ld.append(33.3);
  Ld.add_n(35.5,2);
  //cout << "Ld is: " << Ld << endl;

  Ld.reverse();
  //cout << "Ld is: " << Ld << endl;

  Li.add_n(15,-1);
  Li.add_n(16,0);
  Li.add_n(17,1);
  Li.append(10);
  //cout << "Li is: " << Li << endl;

  Li2.append(5);
  Li2.append(6);
  Li2.add_n(7,2);
  Li2.add_n(8,1);
  //cout << "Li2 is: " << Li2 << endl;

  // You shouldn't use Li2 after the concatenation, because the
  // elements aren't copied, just connected to form one list.

  Li.concat(Li2);
  //cout << "Li is: " << Li << endl;
  //cout << "Li2 is: " << Li2 << endl;

  Li.sort();
  //cout << "Li is: " << Li << endl;

  Li3.append(20);
  Li3.append(10);
  Li3.add_n(50,1);
  Li3.add_n(40,3);
  //cout << "Li3 is: " << Li3 << endl;

  Li.merge(Li3);
  //cout << "Li is: " << Li << endl;
  //cout << "Li3 is: " << Li3 << endl;

  Li3.sort();
  //cout << "Li3 is: " << Li3 << endl;

  // Li3 should not be used after the merge, since the nodes have been removed.

  Li.merge(Li3);
  //cout << "Li is: " << Li << endl;

  Li.add_in(25);
  Li.add_in(4);
  //cout << "Li is: " << Li << endl;

  Li.remove(10);
  Li.remove(50);
  //cout << "Li is: " << Li << endl;

  Ld.add_in(14.3);
  Ld.remove(14.3);
  //cout << "Ld is: " << Ld << endl;

  Ld2 = Ld;
  //cout << "Ld is: " << Ld << endl;
  //cout << "Ld2 is: " << Ld2 << endl;

  Ld.sort();
  //cout << "Ld is: " << Ld << endl;
  //cout << "Ld2 is: " << Ld2 << endl;

  cout << "Li has " << Li.count() << " nodes with a total value of "
      << Li.sum() << endl;

  cout << "Ld has " << Ld.count() << " nodes with a total value of "
       << Ld.sum() << endl;


  return 0;
}

.pro file as requested

#-------------------------------------------------
#
# Project created by QtCreator 2012-09-20T02:33:43
#
#-------------------------------------------------

QT       += core

QT       -= gui

TARGET = List
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp \
    list.cpp

HEADERS += \
    list.h \
    ListNode.h

解决方案

It seems like you forgot to create your List::getNewNode function.

这篇关于collect2:Ld返回1退出状态build make错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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