LNK2001一个无法解析的外部命令还有>=不能转化的问题

问题描述

LNK2001一个无法解析的外部命令还有>=不能转化的问题

 #include<iostream>
#include<string>
#include<map>
#include<cstdlib>

using namespace std;

class User
{
public:
    string rank[3] ={ "beginner", "professional", "expert"};
    string get_name();
    void login();
    void logout();
    bool is_online();
    int get_login_times();
    int get_played_matches();
    int get_won_matches();
    int get_won_ratio();
    string get_rank();
    void play_with(User* another, bool win);
    static User *getUser();// To get the guest
    static User *getUser(string name);// To get the user
    static map<string,User*>user;
private:
    string name_;
    int login_time;
    int played_matches;
    int won_matches;
    bool is_login;
};
string User::get_name()
{
    return this->name_;
}
void User::login()
{
    this->is_login = 1;
}
void User::logout()
{
    this->is_login = 0;
}
bool User::is_online()
{
    return this->is_login;
}
int User::get_login_times()
{
    return this->login_time;
}
int User::get_played_matches()
{
    return this->played_matches;
}
int User::get_won_matches()
{
    return this->won_matches;
}
int User::get_won_ratio()
{
    return played_matches
            ? double(this->won_matches) / (this->played_matches) * 100
            :0.0;
}

string User::get_rank()
{
    if (this->played_matches>= 50&& this->get_won_ratio >= 70)
        return User::rank[1];
    if (this->played_matches >= 100 && this->get_won_ratio >= 80![图片说明](http://img.ask.csdn.net/upload/201605/06/1462520992_907853.png))
        return User::rank[2];
    else
        return User::rank[0];

}
void User::play_with(User* another, bool win)
{
    if (this->is_login&&another->is_login)
    {
        this->played_matches++;
        another->played_matches++;
        win ? (this->won_matches++) : (another->won_matches++);
    }
}

User* User::getUser()// To get the guest
{
    User* p = new User;
    p->is_login = 1;
    p->login_time = 1;
    p->name_ = "guest";
    char buffer[16];
    static int id = 0;
    _itoa(id++, buffer, 10);
    p->name_ += buffer;
    p->played_matches = 0;
    p->won_matches=0;
    user[p->name_] = p;
    return p;
}
User* User::getUser(string name)// To get the user
{
    map<string, User*>::iterator it;
    it = user.find(name);
    if (it != user.end())
        return it->second;
    else
    {
        User* p = new User;
        p->is_login = 1;
        p->login_time = 1;
        p->name_ = name;
        p->played_matches = 0;
        p->won_matches=0;
        user[p->name_] = p;
        return p;
    }
}
int main()
{
    User *guest0 = User::getUser();
        User *guest1 = User::getUser();
        guest0->login();
        guest0->is_online(); // true
        guest0->logout();
        guest0->is_online(); // false
        guest1->get_login_times(); // 0
        User *maoge = User::getUser("Maoge");
        maoge->get_name(); // Maoge
        maoge->login();
        maoge->logout();
        maoge->login();
        maoge->login();
        maoge->get_login_times(); // 2
        User *maogeCopy = User::getUser("Maoge");
        User *kuanye = User::getUser("Kuanye");
        kuanye->play_with(maoge, true);
        kuanye->get_won_matches(); // 0
        kuanye->login();
        kuanye->play_with(maoge, true);
        kuanye->get_won_matches(); // 1
        maogeCopy->get_played_matches(); // 1
        return 0;
}

解决方案

this->get_won_ratio
->
this->get_won_ratio()

还有一些类似的错误,照着一样的修改

解决方案二:

Qt XXXr.obj : error LNK2001: 无法解析的外部符号 3 个无法解析的外部命令问题

时间: 2024-08-29 02:09:50

LNK2001一个无法解析的外部命令还有&amp;gt;=不能转化的问题的相关文章

cuda-CUDA在VS2010下编译出错,无法解析的外部命令

问题描述 CUDA在VS2010下编译出错,无法解析的外部命令 这个是我在网上找的一个例子,没出现红下标,,但是ctrl+F5就有这么多错误,包含头文件的SDK的lib和toolkit的lib路径都添加了,,,不知道为什么出错,,最近才开始学CUDA,请大家多多指教,, 解决方案 可能是Path 路經問題喔 解决方案二: 你对应的lib库文件有没有在工程中设置上.然后就是路径正确

c++-1 个无法解析的外部命令

问题描述 1 个无法解析的外部命令 程序如下:#include#includeusing namespace std;class Time{public:string hour;string min;string sec;}; int main(){void set_time(Time&);void show_time(Time&);Time t1; set_time(t1);show_time(t1);Time t2;set_time(t2);show_time(t2);return 0

错误信息-fatal error LNK1120: 1 个无法解析的外部命令

问题描述 fatal error LNK1120: 1 个无法解析的外部命令 在//初识输入输出 /*程序1的作用是实现两个数的相加*/ #define zt system("pause") #include using namespace std; int jia(int &a,int &b) { return (a+b); } int main() { int jia(int &a,int &b); int a,b; cout<<&quo

源代码-新人求问:程序提示无法解析的外部符号,无法解析的外部命令

问题描述 新人求问:程序提示无法解析的外部符号,无法解析的外部命令 源代码如下 此处为头文件golf.h //headfile golf #ifndef golf const int len=40; struct golf { char fullname[len]; int handicap; }; void setgolf(golf & g,char *name,int hc); int setgolf(golf & g); void handicap(golf & g,int

编程-函数名做函数参数 无法解析的外部命令

问题描述 函数名做函数参数 无法解析的外部命令 #include int main() { float average(float array[10]); float score[10], aver; int i; printf("input 10 score: "); for (i = 0; i < 10; i++) scanf("%f",&score[i]); printf(" "); aver = average(score)

Windows7提示Ping不是内部或外部命令的解决方法

  Windows7提示Ping不是内部或外部命令的解决方法 对于网络管理员来说,经常会需要使用到Ping命令,对服务器相关事项进行检查.但有时在Windows7旗舰版系统中使用Ping命令时,也会遇到不成功,提示"Ping不是内部或者外部命令"的问题,这让不少网管伤透了脑,怎么办?下面就由小编分享Windows7提示"Ping不是内外部命令"的解决技巧. 1.在"计算机"图标上右键选择"属性",在打开的计算机属性设置窗口中选

Java中调用外部命令

Java中调用外部命令 public class ExecCommond{ public ExecCommond(){} /** * 执行一条命令 * @param execStr String 命令字符串 * @return String 执行命令错误时的信息. */ public static String exec(String execStr) { Runtime runtime = Runtime.getRuntime(); 取得当前运行期对象 String outInfo="&quo

在PHP中以root身份运行外部命令[转自linuxaid]

Hunte 2001年4月15日 在PHP中运行只有root用户才可以运行的外部程序,一直是个老问题,用常规的办法很难实现.这是因为一般情况下,PHP是作为APACHE的一个模块的,也就是说,PHP是APACHE的一部分,而APACHE除了suEXEC机制外,是不能以不同的用户ID来执行命令的,但suEXEC机制只能CGI有效. 网上曾经有一篇文章,说用调用"su - -c COMMAND"可以实现,但经过多次试验,发现不行,因为su命令必须在STDIN上输入root的密码. 怎么办?

在PHP中以root身份运行外部命令[转自奥索]

  在PHP中运行只有root用户才可以运行的外部程序,一直是个老问题,用常规的办法很难实现.这是因为一般情况下,PHP是作为APACHE的一个模块的,也就是说,PHP是APACHE的一部分,而APACHE除了suEXEC机制外,是不能以不同的用户ID来执行命令的,但suEXEC机制只能CGI有效. 网上曾经有一篇文章,说用调用"su - -c COMMAND"可以实现,但经过多次试验,发现不行,因为su命令必须在STDIN上输入root的密码. 怎么办?用常规的方法难以奏效,只能再想