C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – 链接器错误LNK2001大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试创建一个对象时,我在Visual studio中得到一个LNK2001错误,这是我认为的构造函数的问题,因为更改构造函数会更改错误.
Customer bob("Bob","25 Bob Lane","01bob82","M","bob/bob/bob");

这一行给出了这个错误:@H_607_5@

Error   1   error LNK2001: unresolved external symbol "public: __thiscall
Customer::Customer(class std::basic_String<char,struct std::char_Traits<char>,class
std::allocator<char> >,class std::basic_String<char,class 
std::allocator<char> >,class
std::allocator<char> >)" (??0Customer@@QAE@V?$basic_String@DU?$char_Traits@D@std@@V?
$allocator@D@2@@std@@0000@z)    D:\DropBox\Work\C++\C++ Assignment\C++ 
Assignment\driver.obj

包含构造函数的Customer类:@H_607_5@

#pragma once
#include "l_list.h"
#include "Account.h"
#include <String>

using namespace std;

class Customer
{
private:
    l_list<Account> accounts;
    String name;
    String address;
    String telNo;
    String sex;
    String dob;

public:
    Customer(String name,String address,String telNo,String sex,String dob)
    {
        Customer::name = name;
        Customer::address = address;
        Customer::telNo = telNo;
        Customer::sex = sex;
        Customer::dob = dob;
    }

    void createAccount()
    {
        cout << "what type of account?";

    }

};

解决方法

如果你有链接错误,那么在语法上你的代码是正常的,否则你会得到编译器错误.

您应该检查(或添加)的是使用Customer类的项目的Dependencies属性中的路径.在VS中,您可以找到它“Project Properties-> Configuration Properties-> Linker-> Input-> Additional Dependencies”.似乎链接器无法通过Customer实现找到外部库.您可以成功编译项目,因为所有#include都是正确的,但由于依赖性,您在链接阶段失败.@H_607_5@

大佬总结

以上是大佬教程为你收集整理的c – 链接器错误LNK2001全部内容,希望文章能够帮你解决c – 链接器错误LNK2001所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。