나는이 내 헤더 파일입니다다른 멤버 내에서 멤버를 오버로드 내 학교 과제에
작은 도움이 필요합니다
#include <iostream>
#include <cstring>
using namespace std;
#include "ISBNPrefix.h"
class ISBN
{
char str[11];
char area[6];
char publisher[8];
char title[7];
bool registered;
public:
ISBN();
ISBN(const char*,ISBNPrefix &);
void toStr(char*)const;
void toStrWithStyle(char*)const;
bool empty()const;
bool isRegistered() const;
bool read(istream& is, const ISBNPrefix& list);
void display(ostream&) const;
};
int isValid(const char* str);
을이 내 파일의 구현 :
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <iomanip>
using namespace std;
#include "ISBN.h"
ISBN::ISBN()
{
str[0]='\0';
area[0]='\0';
publisher[0]='\0';
title[0]='\0';
registered=false;
}
ISBN::ISBN(const char* s,ISBNPrefix& p)
{
if(isValid(s)==1)
{
strcpy_s(str,s);
}
else
{
*this=ISBN();
}
}
bool ISBN::empty()const
{
bool chk=false;
if(str[0]=='\0')
chk=true;
return chk;
}
void ISBN::toStrWithStyle(char* s) const
{
if(registered)
{
sprintf(s,"%s-%s-%s-%c",area,publisher,title,str[9]);
}
else
{
toStr(s);
}
}
void ISBN::toStr(char* s) const
{
if (str[0]!='\0')
strcpy(s,str);
else
strcpy(s,"no data");
}
void ISBN::display(ostream & os) const
{
char str[14];
toStrWithStyle(str);
cout<< setw (13) <<str;
}
int isValid(const char* str)
{
int rc=0;
if(str!=0)
{
int sum,i=0;
sum=0;
for(i=0;i<10;i++)
sum+=(str[i]-'0')*(10-i);
if(sum%11==0)
{
rc= 1;
}
}
else
rc=0;
return rc;
}
bool ISBN::read(istream& is, const ISBNPrefix& list)
{
char str[11];
bool quit=false;
bool ok=false;
char lists;
do{
cout<<"ISBN (0 to quit) : ";
is.getline(str,11); //or is.get(str,11)
if(strcmp(str,"0")==0)
quit=true;
else if (isValid(str)==1)
{
*this=ISBN(str,list);
ok=true;
cout<<"isbn is valid"<<endl;
}
else
{
*this=ISBN();
cout<<"invalid ISBN"<<endl;
}
} while(!quit&&!ok);
return !quit;
}
ISBN::read
여기서 내가 말하는 곳
*this=ISBN(str,list);
다른 회원에게 과부하를 걸고 싶지만 할 수 없습니다. 누구나 저에게 어떻게 할 수 있습니까?
이것은 많은 코드이며, 매우 포맷되지 않은 것입니다. [SSCCE] (http://sscce.org)를 참조하고 사이트를 참조하여 몇 가지 팁 다운 팁을 찾아보십시오. – chris
스택 오버플로에 오신 것을 환영합니다. 최고의 도움을 얻으려면 완전한 예제를 포함하는 것이 좋지만 동시에 문제와 관련없는 코드/정의를 정리/제거해야합니다. 수행 한 조사를 나타내 려하고 문제와 관련된 모든/컴파일러 오류 경고를 포함시켜야합니다. – kfsone
다른 사람이 제안한대로 질문에서 코드를 잘라내어 "과부하"로 무엇을 의미하는지 설명하십시오. 이는 그것이 무엇을 요구하고 있는지 명확하지 않기 때문입니다. C++에서 함수 오버로딩이 있습니다. 그러나 여기에서 설명하는 것과 같은지 확실하지 않습니다. –