Witam, mam następujacy problem z moim programem:
C++ Builder wersja Personal
[Linker Error] Unresolved external 'Cezar::Cezar(int)' referenced from C:\USERS\ZAROBAS\DESKTOP\JACEK - KOPIA\UNIT1.OBJ
[Linker Error] Unresolved external 'Cezar::Koduj(System::AnsiString)' referenced from C:\USERS\ZAROBAS\DESKTOP\JACEK - KOPIA\UNIT1.OBJ
Screen w załączniku na dole.
KOD PROGRAMU:
Unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(OpenDialog1->Execute()){
Memo1->Lines->LoadFromFile(OpenDialog1->FileName);
}
Memo2->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(SaveDialog1->Execute()){
Memo1->Lines->SaveToFile(SaveDialog1->FileName);
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int TForm1::IleZnakow(){
int znaki=0;
if(Memo1->Lines->Count>0){
for(int i=0;i<Memo1->Lines->Count;i++)
znaki+=Memo1->Lines->Strings[i].Length();
}
return znaki;
}
bool TForm1::CzySamogloska(char znak){
char samogloski[5] = {'a','e','i','o','u'};
for(int i=0;i<5;i++)
if(znak==samogloski[i] || znak==UpCase(samogloski[i]))
return true;
return false;
}
int TForm1::IleSamoglosek(){
int ile=0;
for(int i=0;i<Memo1->Lines->Count;i++){
for(int j=1;j<=Memo1->Lines->Strings[i].Length();j++)
if(CzySamogloska(Memo1->Lines->Strings[i][j]))
ile++;
}
return ile;
}
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if (Memo2->Lines->Count>0){
Memo1->Clear();
int klucz=StrToInt(edKlucz->Text);
Cezar c1(-klucz);
for (int i=0;i<Memo2->Lines->Count;i++){
Memo1->Lines->Add(c1.Koduj(Memo2->Lines->Strings[i]));
}
}else ShowMessage("Brak Tekstu");
}
//---------------------------------------------------------------------------
bool TForm1::CzyLitera(char znak){
if(znak>='a' && znak<='z')return true;
if(znak>='A' && znak<='Z')return true;
return false;
}
//_________________
int TForm1::IleLiter(){
int licznik=0;
if (Memo1->Lines->Count>0){
String linia;
for(int i=0; i<Memo1->Lines->Count;i++){
linia= Memo1->Lines->Strings[i];
for(int j=1;j<linia.Length();j++){
if (CzyLitera(linia[j]))licznik++;
}
}
}return licznik;
}
void __fastcall TForm1::btnKodujClick(TObject *Sender)
{
if (Memo1->Lines->Count>0){
Memo2->Clear();
int klucz=StrToInt(edKlucz->Text);
Cezar c1(klucz);
for (int i=0;i<Memo1->Lines->Count;i++){
Memo2->Lines->Add(c1.Koduj(Memo1->Lines->Strings[i]));
}
}else ShowMessage("Brak Tekstu");
}
void __fastcall TForm1::Button6Click(TObject *Sender)
{
if (Memo2->Lines->Count>0 ) {
if(SaveDialog2->Execute()){
Memo2->Lines->SaveToFile(SaveDialog2->FileName);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
if(OpenDialog2->Execute()){
Memo2->Lines->LoadFromFile(OpenDialog2->FileName);
}
Memo1->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Label1Click(TObject *Sender)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel2Click(TObject *Sender)
{
}
//---------------------------------------------------------------------------
Unit2.cpp
//---------------------------------------------------------------------------
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
const int ILELITER=26;
#pragma package(smart_init)
Cezar::Cezar(int klucz){
this->klucz=klucz %ILELITER;
}
bool Cezar::CzyLitera(char znak){
if(znak>='a' && znak<='z')return true;
if(znak>='A' && znak<='Z')return true;
return false;
}
char Cezar::KodujZnak(char znak){
char wynik;
if (CzyLitera(znak)) {
wynik= znak+klucz;
if(!CzyLitera(wynik))wynik=ILELITER;
}
else wynik =znak;
return wynik;
}
String Cezar::Koduj(String linia){
String wynik=linia;
for (int i=1; i<=linia.Length();i++) {
wynik[i]=KodujZnak(linia[i]);
}
return wynik;
}
Unit1.h
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Dialogs.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TPanel *Panel1;
TMemo *Memo1;
TPanel *Panel2;
TMemo *Memo2;
TOpenDialog *OpenDialog1;
TSaveDialog *SaveDialog1;
TButton *Button1;
TButton *Button2;
TButton *btnKoduj;
TEdit *edKlucz;
TUpDown *UpDown1;
TOpenDialog *OpenDialog2;
TSaveDialog *SaveDialog2;
TButton *Button6;
TLabel *Label11;
TButton *Button3;
TButton *Button7;
TLabel *Label1;
TLabel *Label2;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
void __fastcall Button3Click(TObject *Sender);
void __fastcall btnKodujClick(TObject *Sender);
void __fastcall Button6Click(TObject *Sender);
void __fastcall Button7Click(TObject *Sender);
private:
int IleZnakow();
int IleLiter();
bool CzySamogloska(char znak);
int IleSamoglosek();
bool CzyLitera(char znak);
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Unit2.h
//---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
#include <vcl.h>
class Cezar{
private:
int klucz;
bool CzyLitera(char znak);
char KodujZnak(char znak);
public:
Cezar(int klucz);
String Koduj(String linia);
};
//---------------------------------------------------------------------------
#endif
- blad.png (347 KB) - ściągnięć: 210