Mar 15, 2010 at 3:38pm UTC
The whole statement of the ERROR message is"1>Trial.obj : error LNK2028: unresolved token (0A00000E) "public: __clrcall Reg::Reg(int)" (??0Reg@@$$FQAM@H@Z) referenced in function "private: void __clrcall Trial::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@Trial@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)"
Please Help!!!I am panic for this!!!When i use this class in GUI, the error message comes out!
Following is my class:
class Reg// declare the register
{
public:
Reg(int a);
char name[20];
char password[256];
bool creat();
void SetPassword(char password[256]);
bool CheckPassword();
void SetName(char name[20]);
int GenName();
char* GetName();
int GenPassword();
bool login();
bool CheckName();
int counter;
private:
char username[20];
char pword[20];
};
#include <iostream>
using namespace std;
#include <fstream>
#include<string>
#include"Register.h"
Reg::Reg(int a)
{
counter=a;
}
bool Reg::login()
{
if(CheckName()==false&&CheckPassword()==false)
{
cout<<"GOOD!"<<endl;
return true;
}
else {
cout<<"BAD"<<endl;
return false;
}
}
void Reg::SetPassword(char password[256])
{
strcpy(pword,password);
}
bool Reg::CheckPassword()
{
string str;
ifstream record("Password.txt");
for(int i=0;i<counter;i++)
{
getline(record,str);
}
const char*temp=str.c_str();
if(strcmp(pword,temp)==0)
{
return false;
}
return true;
}
bool Reg::CheckName()
{
int c=1;
ifstream record("Name.txt");
string str;
bool flag=true;
//Check wether the name exist.
while(getline(record,str))
{
const char*temp=str.c_str();
if(strcmp(username,temp)==0)
{
flag=false;
counter=c;
}
c=c++;
}
record.close();
return flag;
}
int Reg::GenPassword()
{
ofstream OutPassword("Password.txt",ios::app);
for(int i=0;i<strlen(pword);i++)
{
OutPassword.put(pword[i]);
}
OutPassword.put('\n');
OutPassword.close();
return 0;
}
int Reg::GenName()
{
//Writing the record to Name.txt
if(CheckName()==true)
{
ofstream OutRecord("Name.txt",ios::app);
for(int i=0;i<strlen(username);i++)
{
OutRecord.put(username[i]);
}
OutRecord.put('\n');
OutRecord.close();
GenPassword();
return 0;
}
else{
cout<<"Name exists"<<endl;
return 0;
}
}
void Reg::SetName(char name[20])
{
strcpy(username,name);
}
char* Reg::GetName()
{
return username;
}
bool Reg::creat()
{
if(CheckName()==true)
GenName();
return true;
}
Mar 16, 2010 at 4:42pm UTC
The error seems perfectly self explatory to me.
The linker is saying that it cannot find the function called Reg::Reg(int) which you attempted to call from the Trial::Form1::button1_Click(class System::Object ^,class System::EventArgs ^) function.
Mar 21, 2010 at 10:55am UTC
thanks for your reply, what can i do???