| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 321 人关注过本帖
标题:编译成功 链接出错。。求看看
只看楼主 加入收藏
呢喃君
Rank: 2
等 级:论坛游民
帖 子:32
专家分:28
注 册:2012-7-5
结帖率:83.33%
收藏
已结贴  问题点数:10 回复次数:1 
编译成功 链接出错。。求看看
#include<iostream>
#include<string>
using namespace std;
class User
{
private:
 static string id[20][1];
 static string pw[20][1];
 static char *_pw;
 static int count;
public:
 User(string name,string pass)
 {
  for(unsigned int i=0;i<pass.length();i++)
   _pw[i]=(pass[i]+i+1)%256;//密码加密
  id[0][0]=name;
  pw[0][0]=_pw;
 }
 static void Adduser(string name,string pass)
 {

  for(unsigned int i=0;i<pass.length();i++)
   _pw[i]=(pass[i]+i+1)%256;
  id[count++][0]=name;
  count--;
  pw[count++][0]=_pw;
  return;
 }
 static int login(string name,string pass)
 {
     for(unsigned int i=0;i<pass.length();i++)
   _pw[i]=(pass[i]+i+1)%256;
     pass=_pw;
    for(int i=0;i<count;i++)
        if(name==id[i][0]&&pass==pw[i][0])
            return 1;
        return -1;
         
 }
};

string User::id[20][1];
string User::pw[20][1];
char User::*pw;
int User::count;
int main()
{
 char name[20],pass[20];  
 User u1("LiWei","liwei99");  
 u1.Adduser("ChenHanfu","20090208");  
 User::Adduser("ZhanGaolin","199146");  
 cout<<"Input username:";
 cin>>name;
 cout<<"Input password:";
 cin>>pass;
 if(User::login(name,pass)>=0)   
  cout<<"Success login!"<<endl;
 else
  cout<<"login fail!"<<endl;
 return 0;
}




palace.cpp
Linking...
D:\工具\MinGW\MinGWStudio\palace\Debug\palace.o: In function `ZSt3minIjERKT_S2_S2_':
D:\工具\MinGW\MinGWStudio\palace\palace.cpp:(.text$_ZN4User5loginESsSs[User::login(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x1f): undefined reference to `User::_pw'
D:\工具\MinGW\MinGWStudio\palace\palace.cpp:(.text$_ZN4User5loginESsSs[User::login(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x50): undefined reference to `User::_pw'
D:\工具\MinGW\MinGWStudio\palace\palace.cpp:(.text$_ZN4User7AdduserESsSs[User::Adduser(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x1f): undefined reference to `User::_pw'
D:\工具\MinGW\MinGWStudio\palace\palace.cpp:(.text$_ZN4User7AdduserESsSs[User::Adduser(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x78): undefined reference to `User::_pw'
D:\工具\MinGW\MinGWStudio\palace\palace.cpp:(.text$_ZN4UserC1ESsSs[User::User(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x1f): undefined reference to `User::_pw'
D:\工具\MinGW\MinGWStudio\palace\Debug\palace.o:D:\工具\MinGW\MinGWStudio\palace\palace.cpp:(.text$_ZN4UserC1ESsSs[User::User(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x63): more undefined references to `User::_pw' follow
collect2: ld returned 1 exit status
搜索更多相关主题的帖子: public include private 成功 
2012-10-11 15:35
cyxhxm
Rank: 2
等 级:论坛游民
帖 子:6
专家分:40
注 册:2012-10-11
收藏
得分:10 
貌似在全局声明区域中对类变量_pw的定义不对,其他地方没仔细看
2012-10-11 16:54
快速回复:编译成功 链接出错。。求看看
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029716 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved