类类型的向量导致未解决的外部符号错误LNK2019

cjb_01852

第一个向量,优胜者向量,抛出未解决的外部错误符号错误,我似乎无法确定问题所在。WinnerVector是一个包含Winner类对象的向量。当使用整数实现相同的代码时,不会发生任何问题。

这两个错误如下:“错误1错误LNK2019:无法解析的外部符号“ public:__thiscall Winner :: Winner(class std :: basic_string,class std :: allocator>)”(0Winner @@ QAE @ V?$在函数_wmain C:\ Users \ cjbernier \ Documents \ Classes UML \ UML FALL 2014 \ Computing III中引用的basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ Z) (92.201.202)\ HW6_Templates_STL \ STLtester \ STLtester.obj STLtester“

“错误2错误LNK1120:1个未解决的外部文件C:\ Users \ cjbernier \ Documents \ Classes UML \ UML FALL 2014 \ Computing III(92.201.202)\ HW6_Templates_STL \ STLtester \ Debug \ STLtester.exe 1 1 STLtester”

// STLtester.cpp : Defines the entry point for the console application.
// This program demostrates 5 different STL containers and uses several

#include "stdafx.h"
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <iomanip>
#include <string>
#include <map>

using namespace std;

#pragma once
class Winner {
public:
    Winner(string name = " ");
    void setName(string name);
    const string& getName();
    friend ostream &operator << (ostream &output, const Winner &x);

private:
    string fullName;
};

ostream &operator << (ostream &output, const Winner &x) {
    output << endl << x.fullName;
    return output;
}

int _tmain(int argc, _TCHAR* argv[])
{
        // demonstrating vector template class
        cout << "creating an object of the vector class\n";
        vector<Winner> winnerVector;

        winnerVector.push_back(Winner("George Smith"));

        cout << "the vector contains the following values:\n";
        vector<Winner>::iterator n;
        for (n = winnerVector.begin(); n != winnerVector.end(); n++)
        cout << *n << " ";

        cout << "\n\nadding an element to the vector:\n";
        winnerVector.push_back(Winner("Ron Howard"));

        cout << "the vector now contains the following values:\n";

        for (n = winnerVector.begin(); n != winnerVector.end(); n++)
        cout << *n << " ";

        cout << "\n\nremoving the last element of the vector:\n";
        winnerVector.pop_back();

        cout << "the vector now contains the following values:\n";

        for (n = winnerVector.begin(); n != winnerVector.end(); n++)
        cout << *n << " ";      

    // Demonstrating Vector Template Class  
    cout << "Creating an object of the vector class\n";
    vector<int> intVector;

    cout << "Populating the vector with the integers 0-9\n";
    for (int i = 0; i <= 9; i++) {
        intVector.push_back(i);
    }

    cout << "The vector contains the following values:\n";
    vector<int>::iterator j;
    for (j = intVector.begin(); j != intVector.end(); j++)
        cout << *j << " ";

    cout << "\n\nAdding an element to the vector:\n";
    intVector.push_back(10);

    cout << "The vector now contains the following values:\n";

    for (j = intVector.begin(); j != intVector.end(); j++)
        cout << *j << " ";

    cout << "\n\nRemoving the last 3 elements of the vector:\n";
    intVector._Pop_back_n(3);

    cout << "The vector now contains the following values:\n";

    for (j = intVector.begin(); j != intVector.end(); j++)
        cout << *j << " ";

    // Demonstrating the List Template Class
    cout << "\n\nCreating an object of the list class\n";
    list<char> charList;
    cout << "Populating the list with the letters of the alphabet\n";
    for (char letter = 'A'; letter <= 'Z'; letter++) {
        charList.push_back(letter);
    }

    cout << "The list contains the following values:\n";
    list<char>::iterator k;
    for (k = charList.begin(); k != charList.end(); k++)
        cout << *k << " ";

    cout << "\n\nThe alphabet backwards is:\n";
    list<char>::reverse_iterator rev;
    for (rev = charList.rbegin(); rev != charList.rend(); rev++)
        cout << *rev << " ";

    cout << "\n\nClearing the list:\n";
    charList.clear();
    cout << "The list size is now: " << charList.size();

    // Demonstrating Stack Template Class   
    cout << "\n\nCreating an object of the stack class\n";
    stack<double> doubleStack;

    cout << "Enter a series of double numbers and press enter.\n";
    double nextDouble;
    char nextChar;
    cin.get(nextChar);

    while (nextChar != '\n')
    {
        cin.putback(nextChar);
        cin >> nextDouble;
        doubleStack.push(nextDouble);
        cin.get(nextChar);
    }

    cout << "\nThe double values in reverse order are: \n";
    while (!doubleStack.empty())
    {
        cout << showpoint << setprecision(2) << doubleStack.top() << " ";
        doubleStack.pop();
    }

    // Demonstrating Set Template Class
    cout << "\n\nCreating an object of the set class\n";
    set<string> stringSet;

    stringSet.insert("George Bush");
    stringSet.insert("George Bush");
    stringSet.insert("Fred Johnson");
    stringSet.insert("Chris Lip");

    cout << "The set contains the following Winners:\n";
    set<string>::const_iterator l;
    for (l = stringSet.begin(); l != stringSet.end(); l++)
        cout << "   " << *l << endl;

    cout << "\nSearching for and removing the winner \"Bob Jones\".\n";
    stringSet.erase(stringSet.find("Bob Jones"));

    for (l = stringSet.begin(); l != stringSet.end(); l++)
        cout << "   " << *l << endl;


    // Demonstrating the map class
    cout << "\nCreating an object of the map class\n";
    map<string, string> cars;
    map<string, string>::const_iterator m;

    cout << "Initializing the map:\n";
    cars["Ford"] = "Mustang";
    cars["Honda"] = "Accord";
    cars["Lincoln"] = "MKZ";
    cars["Toyota"] = "Corolla";
    cars["Dodge"] = "Dakota";

    if (cars.empty()) {
        cout << "The map is empty.\n";
    }
    else {
        cout << "The list of cars in the map are:\n";
        for (m = cars.begin(); m != cars.end(); m++)
            cout << m->first << " - " << m->second << endl;
    }

    cout << "\nThe vehicle for Ford is: " << cars["Ford"] << endl << endl;

    if (cars.find("Nissan") == cars.end())
        cout << "Nissan is not in the map.";

    cout << "\n\nThere are vehicles in the map: " << cars.size();

    cout << "\n\nPress any key to exit.";
    cin.get();
    return 0;
}
萨胡

我看到以下问题:

  1. 没有的定义Winner::Winner(std::string)这说明了链接器错误。实际上,我看不到任何成员函数的定义Winner
  2. 什么_Pop_back_n()这不是std::vector我所知道的一部分。它是特定于平台的扩展吗?

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

错误LNK2019:未解决的外部符号,致命错误LNK1120:1未解决的外部

来自分类Dev

错误LNK2019:Qt平台中未解决的外部符号C ++

来自分类Dev

错误LNK2019:未解决的外部符号“公共:__thiscall:构造函数问题

来自分类Dev

xDispatch LNK2019链接器错误未解决的外部

来自分类Dev

xDispatch LNK2019链接器错误未解决的外部

来自分类Dev

LNK2019:未解决的符号

来自分类Dev

LNK2019 和 LNK1120 错误,未解析的外部和未解析的符号

来自分类Dev

是什么导致此LNK2019无法解析的外部符号错误?

来自分类常见问题

如何解决错误LNK2019:无法解析的外部符号-功能?

来自分类Dev

如何解决错误LNK2019:无法解析的外部符号-函数?

来自分类Dev

LNK2019:Visual Studio C ++中无法解决的外部符号错误

来自分类Dev

错误LNK2019:无法解决的外部符号(OpenCV + VS2012)

来自分类Dev

LNK2019:尚未解决的外部符号;我忘了吗?

来自分类Dev

Boost文件系统库中未解析的外部符号(错误LNK2019)

来自分类Dev

C ++:错误LNK2019:函数中引用的未解析的外部符号__snprintf

来自分类Dev

C ++:错误LNK2019:函数_main中引用的未解析的外部符号

来自分类Dev

C ++:错误LNK2019:函数_main中引用的未解析的外部符号

来自分类Dev

LNK2019未解析的QObject外部符号

来自分类Dev

Qt未解析的外部符号LNK2019

来自分类Dev

LNK2019:带有rapidjson的“未解析的外部符号”

来自分类Dev

LNK2019未解析的外部符号SHGetFolderPathW

来自分类Dev

LNK2019:未解析的外部符号-隐式DLL

来自分类Dev

LNK2019未解析的QObject外部符号

来自分类Dev

LNK2019 SHLoadIndirectString的未解析外部符号

来自分类Dev

错误LNK2019无法解析的外部符号-类库问题?

来自分类Dev

收到“错误LNK2019:无法解析的外部符号...”

来自分类Dev

C ++ LNK2019错误:无法解析的外部符号

来自分类Dev

Visual Studio的LNK2019错误-无法解析的外部符号

来自分类Dev

错误:LNK2019:Qt中无法解析的外部符号

Related 相关文章

  1. 1

    错误LNK2019:未解决的外部符号,致命错误LNK1120:1未解决的外部

  2. 2

    错误LNK2019:Qt平台中未解决的外部符号C ++

  3. 3

    错误LNK2019:未解决的外部符号“公共:__thiscall:构造函数问题

  4. 4

    xDispatch LNK2019链接器错误未解决的外部

  5. 5

    xDispatch LNK2019链接器错误未解决的外部

  6. 6

    LNK2019:未解决的符号

  7. 7

    LNK2019 和 LNK1120 错误,未解析的外部和未解析的符号

  8. 8

    是什么导致此LNK2019无法解析的外部符号错误?

  9. 9

    如何解决错误LNK2019:无法解析的外部符号-功能?

  10. 10

    如何解决错误LNK2019:无法解析的外部符号-函数?

  11. 11

    LNK2019:Visual Studio C ++中无法解决的外部符号错误

  12. 12

    错误LNK2019:无法解决的外部符号(OpenCV + VS2012)

  13. 13

    LNK2019:尚未解决的外部符号;我忘了吗?

  14. 14

    Boost文件系统库中未解析的外部符号(错误LNK2019)

  15. 15

    C ++:错误LNK2019:函数中引用的未解析的外部符号__snprintf

  16. 16

    C ++:错误LNK2019:函数_main中引用的未解析的外部符号

  17. 17

    C ++:错误LNK2019:函数_main中引用的未解析的外部符号

  18. 18

    LNK2019未解析的QObject外部符号

  19. 19

    Qt未解析的外部符号LNK2019

  20. 20

    LNK2019:带有rapidjson的“未解析的外部符号”

  21. 21

    LNK2019未解析的外部符号SHGetFolderPathW

  22. 22

    LNK2019:未解析的外部符号-隐式DLL

  23. 23

    LNK2019未解析的QObject外部符号

  24. 24

    LNK2019 SHLoadIndirectString的未解析外部符号

  25. 25

    错误LNK2019无法解析的外部符号-类库问题?

  26. 26

    收到“错误LNK2019:无法解析的外部符号...”

  27. 27

    C ++ LNK2019错误:无法解析的外部符号

  28. 28

    Visual Studio的LNK2019错误-无法解析的外部符号

  29. 29

    错误:LNK2019:Qt中无法解析的外部符号

热门标签

归档